By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,751 Members | 1,046 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,751 IT Pros & Developers. It's quick & easy.

Populate DataGridComboBox dynamically as per value in first column

P: n/a

I need urgent help on Windows Form datagrid. I have to Display a datagrid
that has a textbox column and another one combo box column. I have two tables
in my Access database as:
Table 1:
Columns: Part_ID, Descr
Here Part_ID is Primary key.

Table 2:
Columns: Part_ID, Part_Functions
Here Part_ID refers to column of table above.

Now I need to enter "Descr" value in first textbox column and as per the
corresponding "Part_ID", I need to populate the ComboBox with
"Part_Functions" in second column.

i.e. the Values populated in ComboBox should be correspond to the Part_ID
for that row only. The purpose behind this is that user enters a Description
of Part in first column, from which we can get "Part_MID". Now for second
column, the dropdown should be populated only with values that map to that
Part_MID in Table 2.

This is Windows Form DataGrid not Web Based Datagrid.

Please help me to solve this out.
Will appreciate a quick help,


Sep 28 '05 #1
Share this Question
Share on Google+
1 Reply

P: 4
Check this site :

The only thing that bothers me with this option is that u sort what is in the data and not what u c :(
What I mean is when you have 2 codes in your rows :
Code 1 : representing "ZZZ"
Code 2 : representing "AAA"
Then u 'll c in the column "ZZZ" and "AAA" but when u sort this column he will put "ZZZ" before "AAA" because he'll sort the codes behind the representations (1 and 2).
Have no sollution for this except creating an extra column which actually contains strings (or ints,....) and show this column.

Once you create the comboboxcolumn class, you can use it something like this :
DataGridComboBoxColumn MyComboColumnStyle;
MyComboColumnStyle = new TestComboColumn();
MyComboColumnStyle.ComboBox.DataSource=dtHistTypes ;
MyComboColumnStyle.ComboBox.DisplayMember="Omschri jvingTaal1";
MyDataGridTableStyleProductHistory.GridColumnStyle s.Add(MyComboColumnStyle);
dataGridProductHistory.PreferredRowHeight=MyComboC olumnStyle.ComboBox.Height+1;

Don't mind the strange names in it like "OmschrijvingTaal1", I'm dutch and I don't want to change all the names :D

Hope this helps :)
Sep 28 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.