FranciscoBrito
Member
- Joined
- Aug 25, 2020
- Messages
- 12
- Programming Experience
- Beginner
Hello guys i need a if condition when i write in combobox
See answer here:
ComboBox, TextChanged and SelectedIndexChanged
social.msdn.microsoft.com
Did you see that the OP for that thread was trying to listen ofSkydriver is not what i need, i need when i write in combobox
TextChange
events and he just needed a way to get the correct event when the user types into the combobox? So the answer in that thread was to check if the SelectedIndex
is less than zero when getting the text change event. When the selected index is less than zero, that tells you that the user is typing into the combobox which is what you were asking for in your original post.if(comboBox4.SelectedIndex < 0)
{
listBox1.Items.Add(comboBox4);
int i = 0;
i = comboBox4.SelectedIndex;
comboBox4.Items.RemoveAt(i);
}
else
{
listBox1.Items.Add(comboBox4.SelectedItem);
int i = 0;
i = comboBox4.SelectedIndex;
comboBox4.Items.RemoveAt(i);
}
That is simply an acknowledgement that there is a problem, not a description of the problem. As I have already said, you need to provide a FULL and CLEAR explanation of the problem. What EXACTLY do you expect to happen, what actually does happen and where does the difference occur? You need to have debugged your code using breakpoints and know what the state is and where it differs from your expectations and describe that to us.is not working
I didn't ask you why you were using a ListBox. I asked you why you though it made sense to add a ComboBox to that ListBox. If you want to add selections from the ComboBox then that's fine but that's not what this line is doing:im using a list box because the user gonnna select multiple options of combobox. You got it?
listBox1.Items.Add(comboBox4);