المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Winform DataGridView Host EXTCombo problem



C# Programming
10-05-2009, 09:01 PM
I am writing a DGV which uses the MultiSelect ComboBox code (available from here: http://www.codeguru.com/csharp/csharp/cs_controls/treeview/article.php/c15373/)

I hosted the Control following this MSDN tutorial :
http://msdn.microsoft.com/en-us/library/7tas5c80.aspx

What i've done is this:

- Editng EXTCombo and MultiSelect4Combo Constructor
public EXTCombo()
{
_multiselectList=new MultiSelect4Combo();
this.AddControl(_multiselectList);
this.LoadChildControl);
}
public MultiSelect4Combo()
{
InitializeComponent();
SelectionMode =SelectionMode.MultiExtended;
this.Items.Add("1");
this.Items.Add("2");
}

- Then make EXTCombo implements IDataGridViewEditingControl interface

- Through the EditingControlShowing event, get a reference to the editing control
OnEditingControlSHowing(..)
{
if (dataGridView1.CurrentCell.ColumnIndex==0)
EXTCombo _combo=e.Control as ComboBox;
if (_combo!=null)
{
_combo.SelectedIndexChanged +=OnSelectedIndexChanged;
}
}

OnSelectedIndexChanged(..)
{
string _slectedItems=(string)dataGridView1.CurrentCell.EditedFormatedValue;
dataGridView1.CurrentRow.Cell[0].Value=_selectedItems;
}

The problems are:
- After finish selecting in combobox and click another cell, the new value is not visible (in newly edited cell).
- All other cell (in same column) have the same value as the newly edited cell.
- OnSelectedIndexChanged is not Called at all

Can someone tell me how to fix this? thanks