[RESOLVED] [2005] Datatable as DataSource
Hi All,
I have a data table which has 4 columns. I want to display 1 column and other columns should be invisible. I want to display this column value in a combo box and I've set its properties as follows.
VB Code:
cbo.datasource=dt
cbo.displaymember= dt.columns(1).Tostring
cbo.ValueMember= dt.columns(0).Tostring
Is there any way to add the other columns to a collection, hashtable or something directly. (I.e. not one by one, just setting the datasource)
Any idea will be highly appreciated.
Thanks
Re: [2005] Datatable as DataSource
When the user makes a selection the Selecteditem will return a DataRowView. You can simply index that object to get the other column values, e.g.
vb.net Code:
Dim val As Object = DirectCast(myComboBox.SelectedItem, DataRowView)("ColumnName")
Re: [2005] Datatable as DataSource
Great!!!!
Mr. John
Thank you very much.
It's working perfectly