complex grid with comboboxes

S

Sam

Hi,
I have a datagrid which has (amongst other stuff) 2 comboboxes columns.
So far so good. The trick is that when I select a value in my first
column, it must updates the items of the combobox in the second column
for the same row.

In the first column, comboboxes contain names of tables. In the second
column, comboboxes contain names of the fields in the table selected in
the first column.

Tricky uh ?

Does anybody have an idea ?
Thx
 
S

Sam

Maybe I haven't been clear enough
My problem is that I don't know how to update the datasource of the
comboboxes in the second column regarding what has been selected in the
comboboxes in the first column of the grid (for the corresponding row)
 
P

Philip Hristov

Sam,

Catch the CheckedChanged event of the CheckBoxes in the first column.
Get the state of the checkbox (as well all additional data like the
text and tag property if you use them) which raised the event, get the
current selected row in the DataGrid. Then update the datasource using
the row number which you got and the field of the second column with
checkboxes. This is if I understood you question correctly.

Example:

1. The user checked a checkbox in the first column.
2. The CheckedChanged event is raised.
3. Get which checkbox raised the event and get the information (like
the name of the tables you mentioned and the checkstate)
4. Get the current selected row.
5. Update the second column with checkboxes.

Regards,

Philip.
 
S

Sam

I'm not using checkboxes... I'm using combobox. But that might be the
same principle, isn't it ?
 
S

Sam

Actually it might sounds weird, but in fact the only solution in my
opinion is to modify the datasource of the second column according to
what I've been selected in the first one. The problem ist that it might
(and it's not actually) not be the same values at each row in the first
column. Therefore the datasource should be different for every single
rows of the second column. Is that doable ???
 
P

Philip Hristov

Sam,

It seems I gone crazy! When I red your message, I was seeing checkboxes
not comboboxes, haha! So this is the reason for not understanding your
question before :)
If I understood you correctly you want to select table in the first
column and the fill the second column with the field names of the table
selected in the first one! Is that you are wanting to do?

Then:

1. User chooses a table from the combobox.
2. SelectedIndexChanged event is raised.
3. Get the table name from the combo box.
4. Get field names from the table.
5. Fill the second column's combobox with the field names!
6. The user made his/her choice with the second combobox.
7. SelectedIndexChanged event is raised.
8. Get the field name which the user selected.
9. Put into the datasource! Voila!

As I see maybe you do not know how to get which combobox from the first
column and second column is clicked? Right?

Sam, we shall find a solution to your problem, hope my mind is working
now :)

Philip.
 
S

Sam

Thanks for this reply.
I have solved my problem yesterday, pretty much the way you've
described.
Hope your brain is getting better, lol ;)

Sam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top