Hey everyone...
I've got three problems with a custom DataGridView column I've built
following the "How To: Host Controls in Windows Forms DataGridView
Cells" article. The base editing control is a ComboBox which is
similar to the built-in Combo column but will hopefully be more
flexible.
First: I am using this control in multiple columns which _should_ hold
unique items. However, the items added to column A are visible in
column B, and so on. I'm initializing a new instance of the control
for each column and adding them manually. Why is this happening when
each column have a "new" instance?
MyComboCol colA = new MyComboCol();
MyComboCol colB = new MyComboCol();
MyComboCol colC = new MyComboCol();
// set column A properties
// set column B properties
// set column C properties
myDataGridView.Columns.Add(colA);
myDataGridView.Columns.Add(colB);
myDataGridView.Columns.Add(colC);
Second: As I type text into the control and leave the cell, the text
is automatically added to the Items collection if it doesn't already
exist. This behavior is occurring internally in the class using an
overriden OnLeave event. The problem is that when I move from column A
to column B or a built-in TextBoxColumn, the items in the column A
collection will disappear. I'm assuming that this is related to my
"First" problem, but I'm not certain. Any ideas why this would be
happening?
Third: I'm not able to access the "Items" collection by using
"colA.Items" like you would with DGVComboBoxColumn. I'm calling Base()
and Clone() in my controls class and have set everything to public in
hope that get access to it. How do I expose the EditingControl's
(Inherited ComboBox) Items collection from the Column class?
Thanks for your help,
Mike