S
Simon Harvey
Hi Guys,
I have a small problem with the Windows Forms Combobox control.
I need to allow it to have its Autocomplete behaviour enabled so that
the user can type in items and have the combo suggest values. This works
fine apart from the fact that it allows the user to add entirely new
items to the list - which causes validation problems later on.
Essentially what I would like is for the combobox to work exactly as it
does now, with the exception that if the user presses a key that would
mean that the new text would no longer represent a valid item in the
list - the control should just totally ignore the key press. It should
be as though the user hadn't pressed the key at all.
I've created a class that inherits from the Windows Forms combobox class
and that all works fine - I just can't figure out what to do from there.
I've tried handling things like the TextChanged event and KeyDown event
but I haven't been able to figure out how to get the correct effect.
Does anyone have an example of how to do this? I'm sure it must be very
simple, but I've never really inherited from an existing control.
Any help would be much appreciated
Many thanks in advance
S
I have a small problem with the Windows Forms Combobox control.
I need to allow it to have its Autocomplete behaviour enabled so that
the user can type in items and have the combo suggest values. This works
fine apart from the fact that it allows the user to add entirely new
items to the list - which causes validation problems later on.
Essentially what I would like is for the combobox to work exactly as it
does now, with the exception that if the user presses a key that would
mean that the new text would no longer represent a valid item in the
list - the control should just totally ignore the key press. It should
be as though the user hadn't pressed the key at all.
I've created a class that inherits from the Windows Forms combobox class
and that all works fine - I just can't figure out what to do from there.
I've tried handling things like the TextChanged event and KeyDown event
but I haven't been able to figure out how to get the correct effect.
Does anyone have an example of how to do this? I'm sure it must be very
simple, but I've never really inherited from an existing control.
Any help would be much appreciated
Many thanks in advance
S