473,326 Members | 2,095 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

binding a combobox to a specific column in a DataTable

hello :)

I want to bind a combobox to a specific column in a DataTable.
I want the combobox items to display distinct values.

I tried:
combo.datasource = dataTable;
combo.DisplayMember = "DESIRED COLUMN";

(here I got the values I want, but including empty rows, and with repetitions).
I tried to iterate and check the text of the items, but I can't do "visible = false" since I iterate over datarows,
and I can't remove the specific item from the combobox, since I bound the combobox to a datatable via the datasource property.

do anyone have an idea?

thanks, anat :)
Aug 25 '09 #1
2 8252
cloud255
427 Expert 256MB
Hi, this is why I don't use databindings... you just lose so much control.

What is suggest is that that you loop through the datatable and check if the current item should exist in the items collection of the combobox. If it should then you simply call the Add method to add the item to the combobox.
Aug 25 '09 #2
sorry for the big delay in resonding, but thanks for your help :)
this is what I did at the end

(I iterated over the items in the desired column, and created a dictionary with the values as the key (if it's not contained already in the dictionary) in order to get distinct values only, and then I took all the keys from the dictionary and inserted it to the combobox).
Sep 9 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Omar | last post by:
When I try to databind my comboBox (specifically field "emplcode") to a filled dataset , the contents of the comboBox displays a bunch of "System.Data.DataRowView". I assume the amount of times...
0
by: David | last post by:
Hello, I practice C#, and I would like to change the style of a specific column in a Windows Forms DataGrid - into a ComboBox. Namely, when the user selects that specific column (in any row), he...
0
by: Leeor Chernov | last post by:
Hi , I am using the method: DSSap.ReadXml( XmlPath,XmlReadMode.InferSchema ); And as I expected I get an error when the xml does not matching my DataSet that contains already a schema , The...
0
by: Eran.Yasso | last post by:
Hello all, This is my first time using listview. I was looking in google for a way to write to a specific column. I have 3 columns in my list view. I want to be able to write to a specific...
0
by: Problematic coder | last post by:
Hi, I have just been asked to create an app that will import a specific column from an excel spreadsheet, something like sheet1 columnD or a column with the first row with a value of 'ID'...
6
convexcube
by: convexcube | last post by:
After searching the web for a solution to total a specific column in a list box and not finding it, I came up with this: Dim varTotal As Currency Dim varRow As Integer For varRow = 1 To...
7
by: cesco | last post by:
Hi, I have a file containing four columns of data separated by tabs (\t) and I'd like to read a specific column from it (say the third). Is there any simple way to do this in Python? I've...
2
by: sukatoa | last post by:
I have a table, where it composed of several columns, but i am concerning only on a specific column with datatype varchar under that db table... Now, for example: column: links values: ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.