dcsimg
Results 1 to 5 of 5

Thread: Adding drop down list to DataGridViewTextBoxCell

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,133

    Adding drop down list to DataGridViewTextBoxCell

    Hello

    I wish to give an search functionality to an column in the DGV, such that when the user types any value it searches the DB for values CONTAINING the text and an list of results is displayed below the textbox cell.

    I could have used an ComboBoxCell, but Combobox displays an dropdown for value that STARTS with the given text.

    I looked at Hosting Custom Controls In DGV.

    But if i make an UserControl with TextBox and an Listbox, and show/hide the listbox when the user types in any text, the UserControl will resize within the row height, and the listbox wont be displayed correctly


    Please suggest.

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    102,896

    Re: Adding drop down list to DataGridViewTextBoxCell

    Use the auto-complete functionality built into the TextBox control. Just using a vanilla DataGridViewTextBoxColumn, you can handle the EditingControlShowing event to access the TextBox control that gets embedded in a cell during editing and just use the standard auto-complete functionality.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,133

    Re: Adding drop down list to DataGridViewTextBoxCell

    I tired autocomplete, but TextChange event of textbox if firing as soon as we change/select the item in the dropdown

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    102,896

    Re: Adding drop down list to DataGridViewTextBoxCell

    Quote Originally Posted by aashish_9601 View Post
    I tired autocomplete, but TextChange event of textbox if firing as soon as we change/select the item in the dropdown
    And that's a problem because...?

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,133

    Re: Adding drop down list to DataGridViewTextBoxCell

    Quote Originally Posted by jmcilhinney View Post
    And that's a problem because...?
    Because...suppose i wish to select the 4th item in the dropdown list, no sooner i press the Down arrow key the first item in the list is selected and the textbox text is set to its value, which fires the textchanged event again

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width