Reputation: 1001
I'm new to the C# part of programming, I am currently making a Program that is centered functionally around a ComboBox. In the Combobox, I have a concatenated string that looks like this:
IF checked
("☑ " + client.shortName)
IF unchecked
("☐ " + client.shortName)
So the output would be something like
☐ RealMadrid
As one item in the dropdown list of a comboBox.
My question is, can I implement an event handler that detects when the CheckBox (Not the actual Control Type, more like a character) region of the dropdown is clicked? If yes, Can I get a walk-through on how to do it? (It doesn't have to be a full class, but I would be grateful if It was)
Thanks
Upvotes: 0
Views: 343
Reputation: 112
Wouldn't you be able to use the SelectedIndexChanged event, then just check the first character of the selected value (string) for '☑' or '☐'?
Edit - I think I understand - you want the user to be able to select the item without changing the checkbox 'checked' property, but also allow them to change it if they click towards the left side of the item. You can check the location of the cursor in relation to the form location and determine which side of the combobox they are selecting. It is not necessarily a clean implementation, but I don't think there's another way to fool the program using controls like that.
Upvotes: 1
Reputation: 432
Is there a specific reason to be using a ComboBox as opposed to a number of Checkboxes where the text is updated with the client.shortName?
Upvotes: 0