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. combobox and auto-completion

combobox and auto-completion

Scheduled Pinned Locked Moved C#
questionlearning
5 Posts 4 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.
  • G Offline
    G Offline
    gibono
    wrote on last edited by
    #1

    Hello, i'd like to use a combobox with auto-completion like the one used by internet explorer to browse. How can i do that? Of course i'd like to add any items inside, like "Boat, "Car", "Moto", etc.... Thanks a lot

    D A J 3 Replies Last reply
    0
    • G gibono

      Hello, i'd like to use a combobox with auto-completion like the one used by internet explorer to browse. How can i do that? Of course i'd like to add any items inside, like "Boat, "Car", "Moto", etc.... Thanks a lot

      D Offline
      D Offline
      Dan_P
      wrote on last edited by
      #2

      You need to implement the IAutoComplete2 interface, Have a look here[^] for an example in c#

      1 Reply Last reply
      0
      • G gibono

        Hello, i'd like to use a combobox with auto-completion like the one used by internet explorer to browse. How can i do that? Of course i'd like to add any items inside, like "Boat, "Car", "Moto", etc.... Thanks a lot

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        send mail to me and i will send my own autocomplete combobox dll. ozturk_ferhat@hotmail.com

        1 Reply Last reply
        0
        • G gibono

          Hello, i'd like to use a combobox with auto-completion like the one used by internet explorer to browse. How can i do that? Of course i'd like to add any items inside, like "Boat, "Car", "Moto", etc.... Thanks a lot

          J Offline
          J Offline
          jklucker
          wrote on last edited by
          #4

          Sample c# //************************************************************************************ // Call the corresponding functions from your form's Combobox's KeyUp and // Leave events //************************************************************************************ private void ACCombo_KeyUp(ComboBox cbo, KeyEventArgs e) { //Allow select keys without autocompleting switch(e.KeyCode) { case Keys.Back: case Keys.Left: case Keys.Right: case Keys.Up: case Keys.Delete: case Keys.Down: return; } //Get the typed text and find it on the list string strTypedText = cbo.Text; int intFoundIdx = cbo.FindString(strTypedText); //If we found the typed text in the list then autocomplete if(intFoundIdx >= 0) { //Get the item from the list (Return type depends if datasource was bound //or list created) object objFoundItem = cbo.Items[intFoundIdx]; //Use the listcontrolgetitemtext to resolve the name in case the combo //was data bound string strFoundText = cbo.GetItemText(objFoundItem); //Append then found text to the typed text to preserve case string strAppendText = strFoundText.Substring(strTypedText.Length); cbo.Text = strTypedText + strAppendText; //Select the appended text cbo.SelectionStart = strTypedText.Length; cbo.SelectionLength = strAppendText.Length; } } private void ACCombo_Leave(ComboBox cbo) { int intFoundIdx = cbo.FindStringExact(cbo.Text); cbo.SelectedIndex = intFoundIdx; } Let me know if you need this for VB.NET:) I reject to reality and subsitute my own! - Adam Savage, Mythbuster life is like a roll of toilet paper. The closer it gets to the end, the faster it goes.

          G 1 Reply Last reply
          0
          • J jklucker

            Sample c# //************************************************************************************ // Call the corresponding functions from your form's Combobox's KeyUp and // Leave events //************************************************************************************ private void ACCombo_KeyUp(ComboBox cbo, KeyEventArgs e) { //Allow select keys without autocompleting switch(e.KeyCode) { case Keys.Back: case Keys.Left: case Keys.Right: case Keys.Up: case Keys.Delete: case Keys.Down: return; } //Get the typed text and find it on the list string strTypedText = cbo.Text; int intFoundIdx = cbo.FindString(strTypedText); //If we found the typed text in the list then autocomplete if(intFoundIdx >= 0) { //Get the item from the list (Return type depends if datasource was bound //or list created) object objFoundItem = cbo.Items[intFoundIdx]; //Use the listcontrolgetitemtext to resolve the name in case the combo //was data bound string strFoundText = cbo.GetItemText(objFoundItem); //Append then found text to the typed text to preserve case string strAppendText = strFoundText.Substring(strTypedText.Length); cbo.Text = strTypedText + strAppendText; //Select the appended text cbo.SelectionStart = strTypedText.Length; cbo.SelectionLength = strAppendText.Length; } } private void ACCombo_Leave(ComboBox cbo) { int intFoundIdx = cbo.FindStringExact(cbo.Text); cbo.SelectedIndex = intFoundIdx; } Let me know if you need this for VB.NET:) I reject to reality and subsitute my own! - Adam Savage, Mythbuster life is like a roll of toilet paper. The closer it gets to the end, the faster it goes.

            G Offline
            G Offline
            gibono
            wrote on last edited by
            #5

            Thank you so much jklucker exactly what i wanted

            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