Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. AutoComplete Combobox in datagrid

AutoComplete Combobox in datagrid

Scheduled Pinned Locked Moved C#
graphicsdebugginghelpquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bedevian
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups