.NET Question: Problem with databinding in own custom generic objects.

Joined
Jan 10, 2007
Messages
43,898
Location
In The Machine
Hi All,

I've run into a problem and I thought I'd throw it open to some people more clever than I!

Basically I have created my own 'ConfigKeys' object that under the hood uses a Generic List(of ConfigKey) to do the datastore.
I have a vb.net UI, with a datagridview that uses my object as a datasource.

My problem is that if I add a new ConfigKey to the ConfigKeys list using my object model, the datagridview doesn't show the newly added item, even if I call datagridview.refresh.

Here's some pseudo VB.net code:

private function doAdd()
***oUser.ConfigKeys.add(new ConfigKey("name","value")
***datagridView1.refresh()
end function


The wierd thing is that if I put a breakpoint on the line after the refresh() and query the oUserConfig keys count, it's correct, but the datagridgridview.rows count is 1 less.
The only way I've gotten the grid to update is to disconnect the datasource and reconnect it...

private function doAdd()
***oUser.ConfigKeys.add(new ConfigKey("test","key", "etc")
***datagridView1.datasource = nothing
***datagridView1.datasource = oUser.ConfigKeys()
end function


The grid is still definately connected to the datasource - if I change one of the config keys through the configKeys model, then the grid will show the changes.
I'm guessing there's something I need to do in my object model to tell any databound items that the size of the items has changed??

Any ideas? It's been a while since I've worked on something like this.

Thanks in anticipation.
Richard.




More...

View All Our Microsoft Related Feeds
 
Back
Top