AutoComplete Combobox in datagrid
-
hi can anyone help me to append this code, to have autocomplete combobox in datagrid ? using System; using System.Windows.Forms; using System.Drawing; using System.Data; using System.Diagnostics; namespace Stock { // Derive class from DataGridTextBoxColumn public class DataGridComboBoxColumnNAME : DataGridTextBoxColumn { // Hosted ComboBox control // private AutoCompleteComboBoxNAME comboBox; private ComboBox comboBox; private CurrencyManager cm; private int iCurrentRow; // Constructor - create combobox, register selection change event handler, // register lose focus event handler public DataGridComboBoxColumnNAME() { this.cm = null; // Create ComboBox and force DropDownList style this.comboBox = new ComboBox(); this.comboBox.DropDownStyle = ComboBoxStyle.DropDown; this.comboBox.Sorted = true; // Add event handler for notification of when ComboBox loses focus this.comboBox.Leave += new EventHandler(comboBox_Leave); } // Property to provide access to ComboBox public ComboBox ComboBox { get { return comboBox; } } // On edit, add scroll event handler, and display combo box protected override void Edit(System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Rectangle bounds, bool readOnly, string instantText, bool cellIsVisible) { Debug.WriteLine(String.Format("Edit {0}", rowNum)); base.Edit(source, rowNum, bounds, readOnly, instantText, cellIsVisible); // if (!readOnly && cellIsVisible) { // Save current row in the datagrid and currency manager associated with // the data source for the datagrid this.iCurrentRow = rowNum; this.cm = source; // Add event handler for datagrid scroll notification this.DataGridTableStyle.DataGrid.Scroll += new EventHandler(DataGrid_Scroll); // Site the combo box control within the bounds of the current cell this.comboBox.Parent = this.TextBox.Parent; Rectangle rect = this.DataGridTableStyle.DataGrid.GetCurrentCellBounds(); this.comboBox.Location = rect.Location; this.comboBox.Size = new Size(this.TextBox.Size.Width, this.comboBox.Size.Height); // Set combo box selection to given text this.comboBox.SelectedIndex = this.comboBox.FindStringExact(this.TextBox.Text); // Make the ComboBox visible and place on top text box control this.comboBox.Show(); this.comboBox.BringToFr