Joe Kaminski
asked on
vb.net, datagridview, combobox
I have a datagridview with multiple columns. Two of the columns are comboboxes. The entries in ComboBox2 is based on the entry in ComboBox1. For example, ComboBox1 contains values of 10, 20, 30. Keeping in mind that the datagridview can have multiple rows, when ComboBox1 is set to 10, ComboBox2 should have values of A1, A2, and A3, when ComboBox1 is set to 20, ComboBox2 should have values of B1, B2, and B3, etc. I don't believe I can accomplish this. Therefore, I have two questions.
1. Am I correct?
2. Does anyone have a suggestion of how to accomplish this function?
Thanks.
1. Am I correct?
2. Does anyone have a suggestion of how to accomplish this function?
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Keep in mind that the user will populate the values in ComboBox1 and ComboBox2, i.e., there could be three values in ComboBox1 or 20 values. the same for ComboBox2. Are these examples handling this? Thanks.
pago's suggestion works better, so I suggest you look at it rather than mine.
On whether the user has to input more values, well you never asked for that, but yes, you can incorporate that too!
On whether the user has to input more values, well you never asked for that, but yes, you can incorporate that too!
then you wil have to handle the selectedvaluechanged or selectedindexchanged of combobox1 to populate combobox2.
This is straight foward with mere comboboxes, however with the datagridviewcomboboxes, you will have to handle these events and filter for the grid column index etc
I have some code for you below. It may need some sprucing up bit it does what you asked for. Start a new project and add a datagridview with two comboboxcolumns, then copy the code and run
Open in new window
You need the last handler (data error) because when you start the form the gridview isnot populated and this generates a data error.
DG.png