combobox text write if condition

I'm afraid that your question makes no sense as it is written. You need to provide a FULL and CLEAR explanation of the problem. What are you trying to achieve, how are you trying to achieve it and what happens when you try?
 
ok, this is my application and the code which i need to modify

1598966484554.png

1598966567170.png


In that button i need create one if when the user write in the combobox to export for one listbox, because the code just do if when we select one item on combobox, but i need when we write in the combobox to export too.

It´s better? I´m very bad explain things in english sorry .__.
 
Please post your code in code tags. Screenshots are very hard to read, specially on small devices like phones.
 
Skydriver is not what i need, i need when i write in combobox
Did you see that the OP for that thread was trying to listen of 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.
 
I´m trying that, is not working .__. help. Have someting to add?


C#:
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);
            }
 
is not working
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.

That said, there's some obvious issues with your code. Firstly, the last three lines are the same in both blocks. Either you're doing something you shouldn't in one of those blocks or else those three lines should be moved out of both and written once afterwards. Secondly, how can it possibly make sense to add a ComboBox control to a ListBox? Surely you want to get something from the ComboBox but you haven't explained what that is.

I'm guessing that what you actually mean is that you want the SelectedItem if there is one and the Text otherwise but, if the items are strings, it's actually pointless to differentiate. In that case, if an item is selected then SelectedItem and Text return the same value anyway, so you should just use Text every time.
 
What the listbox have to do with anything? It's just the destination of the user's choice based on the code you have shown. Your original post was asking about the combobox and how to detect when the user types into it.

If there are some other constraints or requirements the you are not telling us about, you should lay them out right away so that we consider those as well, instead of wasting everyone's time getting information piecemeal.
 
im using a list box because the user gonnna select multiple options of combobox. You got it?
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:
C#:
listBox1.Items.Add(comboBox4);
You got it?

I've told you twice now to provide a FULL and CLEAR explanation of the problem and you are still yet to do so. If you expect us to help you fix a problem that you're not prepared to take the time and make the effort to explain then you'll find that we will eventually tire of the experience and you won't get the help you want. Based on my current understanding of your issue, I've already told you what to do in post #9. If that doesn't solve the problem then my current understanding of the problem is not accurate and that is because you haven't explained the problem properly.
 
Back
Top Bottom