Groups | Blog | Home
all groups > dotnet windows forms databinding > february 2006 >

dotnet windows forms databinding : Selectively populating ComboBoxColumns in a DataGridView


Kjell
2/14/2006 4:34:52 AM
I'm trying to use a DataGridView to list a number of artifacts from a
DataTable. As there can be duplicate instances of one artifact stored on the
disk there is also a related "Source" DataTable that holds the file paths to
each instance of an artifact. Now I want to include a ComboBoxColumn in my
DataGridView of artifacts to choose one particular inctance for each artifact
to be my master instance.

The problem now is that each ComboBoxColumn schould be populated with just
the instances related to the particular artifact described on that row, not
with the entire "Source" table.

I have bound a DataView of the "Source" DataTable to the ComboBoxColumn
allright, but I have failed to find any useful event to let me set the
RowFilter when a particular ComboBoxCell is about to be populated. It looks
like all visible ComboBoxCells are repopulated each time a row is entered or
edited.

Can this be done, or are there other techniques to achive the result I'm
Bart Mermuys
2/14/2006 1:54:59 PM
Hi,

[quoted text, click to view]

The basic idea is to have two BindingSource's (linked to the same lookup
table). One is filtered on the fly, the other one is always unfiltered.

When DataGridView.CellBeginEdit is fired, you (re)filter the filtered
BindingSource and assign it to ComboBoxCell.DataSource.

When DataGridView.CellEndEdit is fired, you assign the unfiltered
BindingSource back to the ComboBoxCell.DataSource.

Have a look at the thread in this newsgroup from a week ago:
http://tinyurl.com/94osm

And this one:
http://tinyurl.com/77rlp

HTH,
Greetings



[quoted text, click to view]

AddThis Social Bookmark Button