#region the class apply to initialize combo column in datagrid
public delegate void ComboValueChanged( int changingRow, object newValue );
// Step 1. Derive a custom column style from DataGridTextBoxColumn
// a) add a ComboBox member
// b) track when the combobox has focus in Enter and Leave events
// c) override Edit to allow the ComboBox to replace the TextBox
// d) override Commit to save the changed data
public class DataGridComboBoxColumn : DataGridTextBoxColumn
{
public NoKeyUpCombo ColumnComboBox = null;
private System.Windows.Forms.CurrencyManager _source = null;
private int _rowNum;
private bool _isEditing = false;
ComboValueChanged _valueChanging;
public DataGridComboBoxColumn(ComboValueChanged valueChanging) : base()
{
_valueChanging = valueChanging;
ColumnComboBox = new NoKeyUpCombo();
ColumnComboBox.Leave += new EventHandler(LeaveComboBox);
//ColumnComboBox.Enter += new EventHandler(ComboMadeCurrent);
ColumnComboBox.SelectedIndexChanged += new System.EventHandler(ComboIndexChanged);
ColumnComboBox.SelectionChangeCommitted += new System.EventHandler(ComboStartEditing);