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. Combo Box value set problem

Combo Box value set problem

Scheduled Pinned Locked Moved C#
csharphelp
3 Posts 2 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.
  • R Offline
    R Offline
    raju_shiva
    wrote on last edited by
    #1

    Hi sir, When i type in combo edit box any character,i am find the character typed with the string. Its all working fine. But the problem i am facing is 1) When i select any value from the dropdown combo, the value is not setting to edit box combo,as the dropdown is showing again 2)After getting the dropdown list,if i tried to select the value from keyboard "i.e by pressing down key arrow", the value is not setting and i am getting empty value in edit box. Here is the code ,i am trying with

    private void comboBox1_TextChanged(object sender, EventArgs e)
    {
    int j = 0;
    string str,strTemp,str1;
    str = comboBox1.Text;
    comboBox1.Items.Clear();
    for (int i = 0; i < List.Count; i++)
    {
    j++;
    string value = List[i] as string;
    str1 = value.ToUpper();
    strTemp = str.ToUpper();
    if (str1.IndexOf(strTemp) != -1)
    {
    j++;
    comboBox1.Items.Add(value);
    }
    }

            int k = str.Length;    
            comboBox1.Select(k, k++);            
            comboBox1.DroppedDown = true;
           
        }
    

    As i am new to C#.I am confused a bit. Any idea will be really helpful Thanks Raj

    S 1 Reply Last reply
    0
    • R raju_shiva

      Hi sir, When i type in combo edit box any character,i am find the character typed with the string. Its all working fine. But the problem i am facing is 1) When i select any value from the dropdown combo, the value is not setting to edit box combo,as the dropdown is showing again 2)After getting the dropdown list,if i tried to select the value from keyboard "i.e by pressing down key arrow", the value is not setting and i am getting empty value in edit box. Here is the code ,i am trying with

      private void comboBox1_TextChanged(object sender, EventArgs e)
      {
      int j = 0;
      string str,strTemp,str1;
      str = comboBox1.Text;
      comboBox1.Items.Clear();
      for (int i = 0; i < List.Count; i++)
      {
      j++;
      string value = List[i] as string;
      str1 = value.ToUpper();
      strTemp = str.ToUpper();
      if (str1.IndexOf(strTemp) != -1)
      {
      j++;
      comboBox1.Items.Add(value);
      }
      }

              int k = str.Length;    
              comboBox1.Select(k, k++);            
              comboBox1.DroppedDown = true;
             
          }
      

      As i am new to C#.I am confused a bit. Any idea will be really helpful Thanks Raj

      S Offline
      S Offline
      Stanciu Vlad
      wrote on last edited by
      #2

      I think that using comboBox1.Items.Clear(); is not a correct thing to do (it messes up all you selected items and so on). All your code can be replaced (if you use .net 2 or greater) with the functionality of the autocomplete[^] feature.

      I have no smart signature yet...

      R 1 Reply Last reply
      0
      • S Stanciu Vlad

        I think that using comboBox1.Items.Clear(); is not a correct thing to do (it messes up all you selected items and so on). All your code can be replaced (if you use .net 2 or greater) with the functionality of the autocomplete[^] feature.

        I have no smart signature yet...

        R Offline
        R Offline
        raju_shiva
        wrote on last edited by
        #3

        Hi sir, Thanks a lott,its working fine now. Thanks Raj

        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