how to delete a ComboBox item

  • Thread starter Thread starter Franky
  • Start date Start date
F

Franky

I have a usercontrol that inherits from ComboBox

I'd like to add the feature that the user can delete any item

Best would be that he could right click an element and a messagebox would
ask if he wanted to delete that element

I can't find an event that would enable me to do that.

I could copy the items into a text box, let him edit it and put them back

Not to fond of that

Got any other idea of how it might be done??


Thanks
 
Franky,

It is very important to answer you in that how your combobox is populated.
One of the meanings of combo is that you can do it from a datasource and
from an inbuild array.

Cor
 
Morning Cor ,

How are you doing ?

Cor Ligthert said:
Franky,

It is very important to answer you in that how your combobox is populated.
One of the meanings of combo is that you can do it from a datasource and
from an inbuild array.

Cor
 
Missed you a while saw your previous message, are you going to be again
active here?

Cor
 
I'm going to try, but I've been incredibly busy with commerical work so I'll
probably be contributing in little bursts.
 
Populated from things the user previously typed into the ComboBox's Text box

Thanks for the interest
 
Franky,

Than you can just find the index with findstringexact and remove the index.

Cor
 
Cor

This is more a design question rather that an implementation question.

I know how to delete items.

I can't think of a neat way for the user to select the items to be deleted.

One possibility is for the user to click an item so that it appears in the
text box, and the button might say "Delete item showing in Textbox"

It just occurred to me that the items might be able to display a checkbox
next to them - is that possible in a combobox -I'll have to check. If that
is possible the user could check the items to be deleted while the dropdown
list is showing.

A quick test led me to believe Combobox gets a click event if I click in the
textbox or cause a dropdown. It does not get one if I click and item in the
dropdown.

Maybe in WndProc I could catch the right click and figure out which item the
user clicked. Does that seem like a way to go???


....



....
 
Franky,

Why you don't simple drag a contextmenustrip on your form
Set the first menu
Set that as property in the combobox

And you are almost ready,

Cor
 
Cor

In Opening I built a contextmenustrip that has items like

Delete EXE
Delete TXT

The items in the combobox being EXE and TXT

Clicking one deletes it

Very nice


Thanks
 
Back
Top