|
-
Oct 13th, 2021, 03:54 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] ComboBox Behaviour
I have a comboBox with items that are added or deleted at runtime.
Sometimes I need the combobox to display "Varies" where no specific selection applies.
A normal comboBox highlights the text once you click it but you can then highlight portions or set the cursor at a specific position in the text.
I currently add a Click event to remove "Varies".
HTML Code:
Private Sub ComboBox1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ComboBox1.Click
If ComboBox1.Items.Contains("Varies") Then ComboBox1.Items.Remove("Varies")
End Sub
But
1: This disables this normal functionality. Everytime I click it highlights the full text.
2: If I press escape without selecting another item it returns the combobox.text as "" which I really need to go as unhandled and revert to "Varies"
Hope someone can help.
-
Oct 13th, 2021, 07:42 PM
#2
Re: ComboBox Behaviour
Is the DropDownStyle set to DropDown or DropDownList? Which do you want it set to? The former allows you to enter text that does not correspond to an item while the latter will only accept an in-list selection. If you want to just be able to set the Text to "Varies" without that being an item, use the former.
-
Oct 14th, 2021, 01:27 AM
#3
Thread Starter
Fanatic Member
Re: ComboBox Behaviour
Hi jmcilhinney,
I use both.
Your reply made me understand that my question was about two problems that were specific to each type of combobox you mention.
Dropdown I should be simply adding "Varies" as text, and not an item, and solves the first question.
DropDownList I'll need to re add "Varies" if the user presses escape without making a valid selection.
Thanks again!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|