Marc,
Can you (briefly) remind me what the purpose of this custom column is?
Custom column is used to host virtual foreign key ComboBox.
There may be 50000 customers in customer table. So customer name combobox
data source should be populated dynamically.
I use subclassed DataGridViewCom boBoxCell GetFormattedVal ue() event to
populate combobox datasource
on the fly by calling Combobox datasource bindinglist special
AddIfNotExists( )
method:
protected override object GetFormattedVal ue(object value, int rowIndex, ref
DataGridViewCel lStyle cellStyle,
TypeConverter valueTypeConver ter, TypeConverter formattedValueT ypeConverter,
DataGridViewDat aErrorContexts context) {
ComboBoxColumn comboBoxColumn = OwningColumn as ComboBoxColumn;
comboBoxColumn. PickList.AddIfN otExists(value) ;
return base.GetFormatt edValue(value, rowIndex, ref cellStyle,
valueTypeConver ter, formattedValueT ypeConverter, context);
Custom combobox column implementation is required to allow grid to
host this combobox.
I havent way any other method to allow enter customers by name in grid.
I'm reaching the conclusion that (sample or not) trying to implement
this from scratch is going to be hard;
Probably DataGridView does not call ICancelAddNew.E ndNew() method.
New is remains in uncommited state when AddNewCore() is called. AddNewCore()
throws Invalid Operation exception.
I think there must be simple one line fix which fixes this. Probably
something simple is missing or wrong in custom column implementation. Or is
it possible to call EndNew() method itself from this code ?
can you not just modify the behavior of the existing control?
Should I really add event hander to GetFormattedVal ue() method ? There are
also other methods which needs to be overridden.
Should I try to add event handlers into all places ? MSDN recomments
subclassing and overriding methods as preferred technique for this.
>For example - if you just want to
support up/down keys etc:
The goal is to allow enter data using foreign keys when lookup table is big
and
resides in server.
Andrus.