473,474 Members | 1,822 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Combobox - autocomplete, allow deletion (removal) of selection, limit to list

1 New Member
I have many ComboBoxes with DataSource set to a binding source which is a list of values and display text.

My requirements for these ComboBoxes were:
- limit the user to choosing items in the list only
- if the user selects an item, then changes their mind they should be able to delete the selected item so that the combobox is blank and no item is selected
- if the user presses some keys the item in the list beginning with those characters should be selected automatically

By the way these requirements are very easily met in MS Access VBA, but not in VB.NET .

The DropDownStyle "DropDownList" limits the user to the list, but does not allow a user to select an item and then remove that selection.

The DropDownStyle "DropDown" does not limit the user to the list, but does allow the user to select an item and then remove that selection.

Therefore my solution was as follows:
- use the "DropDown" dropdownstyle
- set AutoCompleteMode to Append and AutoCompleteSource to ListItems
- put this code in every form which has comboboxes (comboboxes with names cmb_x, cmb_y, cmb_z):

Private Sub ComboboxValidating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles cmb_x.Validating, cmb_y.Validating, cmb_z.Validating
Dim TheBox As ComboBox
TheBox = sender
If TheBox.SelectedIndex = -1 And TheBox.Text <> "" Then
TheBox.Text = ""
End If
End Sub

This means that if the user types something which is not in the list, what they type simply disappears.
Dec 30 '11 #1
0 4114

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: VM | last post by:
How can I implement the autocomplete functionality in a Windows comboBox? Thanks.
19
by: Bernie Yaeger | last post by:
Everyone misses the point on this - what we need is a combobox autocomplete that is a dropdownlist only. When in dropdown mode, you can enter text - making that autocomplete is trivial. But when...
0
by: peter78 | last post by:
I wanted to implement an autocomplete feature on the combobox where you would type in partial text and it would try to match it for you. It doesn't exist in .Net yet, but I'm guessing it will in...
0
by: Rich | last post by:
Hello, I found this code on google for autocompleting text from a combobox. The works fine. It was the shortest sample of the samples I found. I added a few extra keys to ignore on keyup like...
1
by: David Tilman | last post by:
I'm working with C# in Visual Studio 2005. I have a combobox with AutoCompleteSource = ListItems and DropDownStyle = DropDown. I want users to be able to type in the combobox and the control to...
2
by: dneupane | last post by:
Hi all How can I get combobox autocomplete working with button click event, my application cannot use keyboard, so I have soft keypad. Any help would be greatly appreciated. Regards Niju
6
by: ezyeric13 | last post by:
I have a series of ComboBox's Bound to a DataGridView and I turned the AutoComplete on for them so they list all the items in a certain collumn of the DataGridView. The problem is that when you...
8
by: jw5et | last post by:
I have a form which you can enter comments on individuals. There is a text box (Informant), where the same data was entered over & over. To make data entry faster, I've made Informant into combo...
5
by: igalep132 | last post by:
Hey, I've a comboBox with some List Items (countries names) I was wondering how can I force the user to select those countries which are Listed in the collection list only, without any...
0
by: =?Utf-8?B?UiBSZXllcw==?= | last post by:
Hi - I've been searching around for a fix but can't find one... There is a bug with combobox autocomplete suggestappend. When text has a slash, "ab/cd" for example, the autocomplete feature cuts...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.