vb.net - Binding ComboBox to DataTable That is not in Dataset -


i using vb.net develop small application. want bind combobox datatable not in dataset. binding dataset follows:

bsos=new bindingsource(ds,"tablename") 

assume created own distinct table values follows:

tblos = dstaset.tables("computers").defaultview.totable(true, "os") 

what want following:

bsos = new bindingsource(tblos) 

but error comes:

unable cast object of type 'system.data.datatable' type 'system.componentmodel.icontainer'. 

is there away without adding table dataset?

this should work:

combobox.datasource = tblos combobox.valuemember = "<column name want value>" combobox.displaymember = "<column name value want display in list>" 

to update datasource values can this:

dim tblos datatable = combobox.datasource dim dr datarow = tblos.newrow() dr.item(0) = "value" dr.item(n) = "display" 

since datatable isn't bound doubt possible update automatically. if keep tblos property, instead of local variable, update combobox gets new row.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

android - IBM Worklight 6.1 [Application Error] There was a network error (file:///android_asset/www/index.html) -