Click here to Skip to main content
15,886,362 members
Home / Discussions / C#
   

C#

 
GeneralRe: How do I inherit ComboBox to implement my function Pin
Dave Kreskowiak22-Feb-14 8:11
mveDave Kreskowiak22-Feb-14 8:11 
GeneralRe: How do I inherit ComboBox to implement my function Pin
BillWoodruff22-Feb-14 8:30
professionalBillWoodruff22-Feb-14 8:30 
GeneralRe: How do I inherit ComboBox to implement my function Pin
Ravi Bhavnani22-Feb-14 11:15
professionalRavi Bhavnani22-Feb-14 11:15 
GeneralRe: How do I inherit ComboBox to implement my function Pin
Dave Kreskowiak23-Feb-14 4:47
mveDave Kreskowiak23-Feb-14 4:47 
GeneralRe: How do I inherit ComboBox to implement my function Pin
Ravi Bhavnani23-Feb-14 6:34
professionalRavi Bhavnani23-Feb-14 6:34 
GeneralRe: How do I inherit ComboBox to implement my function Pin
Richard MacCutchan23-Feb-14 21:59
mveRichard MacCutchan23-Feb-14 21:59 
GeneralRe: How do I inherit ComboBox to implement my function Pin
Member 1041329223-Feb-14 13:53
professionalMember 1041329223-Feb-14 13:53 
AnswerRe: How do I inherit ComboBox to implement my function Pin
BillWoodruff22-Feb-14 4:48
professionalBillWoodruff22-Feb-14 4:48 
I am sure you learned a lot implementing a custom ComboBoxItem using 'OnDrawItem. As you've found out, trying to access the hidden internal ListView that is displayed when the ComboBox drops its DropDown is problematic.

The only Event I've found that lets you determine the location of the mouse for any action in a ComboBox DropDown, without using WinAPI, is the SelectedIndexChanged Event. Consider:
C#
private private Point hitPoint;

private int deleteThreshold = 100;

private void SomeComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
    hitPoint = SomeComboBox.PointToClient(MousePosition);

    // in any "real world" solution, I'd put up a confirmation DialogBox here before allowing a delete
    if(hitPoint.X > deleteThreshold) SomeComboBox.Items.Remove(SomeComboBox.SelectedItem);
}
You could simplify this in a way that does not require 'OnDrawItem, however, the "sacrifice" would be that you would include the "X" as part of the Text of the ComboBoxItem itself, so the "X" could not appear in any special Font, not have any special formatting.

If you want to see an example of this, just let me know, and I'll post sample code here.
“The best hope is that one of these days the Ground will get disgusted enough just to walk away ~ leaving people with nothing more to stand ON than what they have so bloody well stood FOR up to now.” Kenneth Patchen, Poet

GeneralRe: How do I inherit ComboBox to implement my function Pin
Member 1041329223-Feb-14 13:50
professionalMember 1041329223-Feb-14 13:50 
GeneralRe: How do I inherit ComboBox to implement my function Pin
BillWoodruff23-Feb-14 14:06
professionalBillWoodruff23-Feb-14 14:06 
Questionslow motion problem in picture box... Pin
Edalat_201121-Feb-14 21:36
Edalat_201121-Feb-14 21:36 
AnswerRe: slow motion problem in picture box... Pin
BillWoodruff22-Feb-14 9:11
professionalBillWoodruff22-Feb-14 9:11 
AnswerRe: slow motion problem in picture box... Pin
TnTinMn23-Feb-14 11:10
TnTinMn23-Feb-14 11:10 
QuestionAcroRd32.exe command line options and alternatives Pin
kranthi198821-Feb-14 10:58
kranthi198821-Feb-14 10:58 
AnswerRe: AcroRd32.exe command line options and alternatives Pin
Garth J Lancaster21-Feb-14 11:14
professionalGarth J Lancaster21-Feb-14 11:14 
Questionhow to use a key in md5 algorithm in c# Pin
rincy sivan21-Feb-14 0:22
rincy sivan21-Feb-14 0:22 
AnswerRe: how to use a key in md5 algorithm in c# PinPopular
Eddy Vluggen21-Feb-14 0:27
professionalEddy Vluggen21-Feb-14 0:27 
GeneralRe: how to use a key in md5 algorithm in c# Pin
OriginalGriff21-Feb-14 0:57
mveOriginalGriff21-Feb-14 0:57 
AnswerRe: how to use a key in md5 algorithm in c# PinPopular
OriginalGriff21-Feb-14 1:03
mveOriginalGriff21-Feb-14 1:03 
JokeRe: how to use a key in md5 algorithm in c# Pin
Marco Bertschi21-Feb-14 1:18
protectorMarco Bertschi21-Feb-14 1:18 
GeneralRe: how to use a key in md5 algorithm in c# Pin
OriginalGriff21-Feb-14 3:30
mveOriginalGriff21-Feb-14 3:30 
GeneralRe: how to use a key in md5 algorithm in c# Pin
harold aptroot21-Feb-14 1:44
harold aptroot21-Feb-14 1:44 
AnswerRe: how to use a key in md5 algorithm in c# Pin
AmitGajjar23-Feb-14 18:48
professionalAmitGajjar23-Feb-14 18:48 
Questionweb browser Pin
Member 1045906320-Feb-14 23:42
Member 1045906320-Feb-14 23:42 
AnswerRe: web browser Pin
OriginalGriff21-Feb-14 0:07
mveOriginalGriff21-Feb-14 0:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.