Combo Box value set problem
-
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
-
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
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...
-
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...
Hi sir, Thanks a lott,its working fine now. Thanks Raj