Highlight Item in ComboBox? [RESOLVED] !!!
I know that I can use .Selected(0) in a listbox, but I need to do the same thing in a ComboBox. I set the .ListIndex and .TopIndex to 0, but the item isn't selected (highlighted). I want it to be visible on the screen.
What am I overlooking? There is no .Selected property!
Re: Highlight Item in ComboBox?
If the Style = 1 the Combo1.ListIndex = 2 will do it.
Re: Highlight Item in ComboBox?
The style is 0, but if I make it 1, then selecting the index of 2 calls the third item into view, but it still isn't selected. If I click it, then it is highlighted. I want it highlighted before clicking on it.
.ListIndex = 1 shows the second item, so I know that it is correct to use 0 for the value. there must be another way to actually HIGHLIGHT it.
Re: Highlight Item in ComboBox?
So you want to select an item in a combobox from the code ?
Like let's say you want to initialise your form and you need to select the 2nd item in the combobox before the user click on it?
Or if it's something else, maybe you can paste your code and explain what you expect to see?
Re: Highlight Item in ComboBox?
when I set the selected item (first item [0]), it appears, but is not highlighted. the default for a new project does highlight it. not sure what could have happened.
1 Attachment(s)
Re: Highlight Item in ComboBox?
Just so there's no question - ListIndex always starts at 0. Try this little form.
Re: Highlight Item in ComboBox?
I want mine to work like the middle one, so the item is highlighted. my combo looks like the third one, which doesn't highlight the item when you click the button.
hmmm, when I change mine to style 1, it still doesn't highlight the item.
what could be wrong?
Re: Highlight Item in ComboBox?
Is the hieight of the combobox extended like my middle one? If not then that's the problem because it has to be extended to work. If it is extended then put a breakpoint on this line cboStyle1.ListIndex = 1 (or the equivalent in your program) and step through the code because something is unselecting it.
Re: Highlight Item in ComboBox?
If I understand your problem correctly, could you not just do this:
Code:
Combo1.ListIndex = whatever
Combo1.SelStart = 0
Combo1.SelLength = Len(Combo1.Text)
Re: Highlight Item in ComboBox?
it's not extended. i will try the other method.
Re: Highlight Item in ComboBox?
Hey, that did it. Thanks, Pete.
Now, to get the flicker problem with msgbox resolved.