Update datagridview from three comboboxes

pettrer

Well-known member
Joined
Sep 5, 2008
Messages
92
Programming Experience
10+
Hi,

I have three comboboxes in a form. The first is the parent of the second, which is the parent of the third. When they are all updated, a datagridview should be updated.

The problem is that the user can choose to change the value of either combobox, so I don't know which combobox's value is being changed. Therefore I now update the datagridview from the third combobox's selectedvaluechanged event. This unfortunately means that if the first combobox is changed, the second and third comboboxes selectedvalue events must trigger. As a consequence, when the first combobox is changed, the datagridview is being updated about six times (which doesn't work for me performancewise).

What I'd like to do is to call the updatedatagridview sub from either one of the three comboboxes, but only if the user has chosen to change that specific combobox's value (that is, get the form to only update the datagridview when the selectedvalues of all three comboboxes have been set). Is that possible? Or how should I do it???

Puzzled!

Petter
 
The SelectionChangeCommitted event is raised only when the user explicitly selects a new item in the ComboBox, as opposed to the SelectedIndexChanged event, which is raised every time the SelectedIndex property value changes.

How exactly are you getting the data? Are you getting it all and then filtering it or are you getting only the data you need when you need it? If it's the former then you can have the grid updated automatically and you won't need any code at all.
 
Hello again,

Thanks for your informative reply. No, I can't (and don't want to :) ) get the data updated automatically in this case.

I'm very grateful for telling me about the event - I hadn't heard of it before.

Thanks again,

Pettrer
 
Back
Top