|
-
Mar 5th, 2008, 01:14 AM
#1
Thread Starter
Hyperactive Member
[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
If the post is heplful, Please Rate it
Chathura Wijekoon
-
Mar 5th, 2008, 02:21 AM
#2
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")
-
Mar 5th, 2008, 05:34 AM
#3
Thread Starter
Hyperactive Member
Re: [2005] Datatable as DataSource
Great!!!!
Mr. John
Thank you very much.
It's working perfectly
If the post is heplful, Please Rate it
Chathura Wijekoon
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|