Click here to Skip to main content
15,884,176 members
Home / Discussions / C#
   

C#

 
GeneralRe: Delete From XML File Pin
Kevin Marois28-Aug-12 11:16
professionalKevin Marois28-Aug-12 11:16 
GeneralRe: Delete From XML File Pin
PIEBALDconsult28-Aug-12 11:36
mvePIEBALDconsult28-Aug-12 11:36 
AnswerRe: Delete From XML File Pin
PIEBALDconsult28-Aug-12 11:35
mvePIEBALDconsult28-Aug-12 11:35 
GeneralRe: Delete From XML File Pin
Kevin Marois28-Aug-12 11:47
professionalKevin Marois28-Aug-12 11:47 
GeneralRe: Delete From XML File Pin
PIEBALDconsult28-Aug-12 12:07
mvePIEBALDconsult28-Aug-12 12:07 
GeneralRe: Delete From XML File Pin
Kevin Marois28-Aug-12 12:21
professionalKevin Marois28-Aug-12 12:21 
AnswerRe: Delete From XML File Pin
PIEBALDconsult28-Aug-12 12:02
mvePIEBALDconsult28-Aug-12 12:02 
QuestionHow can I change this event handler? Pin
turbosupramk328-Aug-12 10:52
turbosupramk328-Aug-12 10:52 
Hi,

I'm not well versed on event handling and I'd like to pass a color to this method, instead of having it choose the color based on the value of e.index. Can anyone tell me how to change the method below to do that?

Thanks for reading.

C#
void listBox_DrawItem(object sender, DrawItemEventArgs e)
{
    if (e.Index > -1)
    {
        if (e.Index == 0)
            e.Graphics.FillRectangle(Brushes.Red, e.Bounds);
        else if (e.Index == 1)
            e.Graphics.FillRectangle(Brushes.Green, e.Bounds);
        else
            e.DrawBackground();
        using (Brush textBrush = new SolidBrush(e.ForeColor))
        {
            e.Graphics.DrawString(lbxOutput.Items[e.Index].ToString(), e.Font, textBrush, e.Bounds.Location);
        }
    }
}

AnswerRe: How can I change this event handler? Pin
Richard Andrew x6428-Aug-12 11:08
professionalRichard Andrew x6428-Aug-12 11:08 
GeneralRe: How can I change this event handler? Pin
turbosupramk328-Aug-12 14:32
turbosupramk328-Aug-12 14:32 
GeneralRe: How can I change this event handler? Pin
Richard Andrew x6428-Aug-12 15:20
professionalRichard Andrew x6428-Aug-12 15:20 
GeneralRe: How can I change this event handler? Pin
turbosupramk328-Aug-12 15:24
turbosupramk328-Aug-12 15:24 
GeneralRe: How can I change this event handler? Pin
Richard Andrew x6428-Aug-12 15:37
professionalRichard Andrew x6428-Aug-12 15:37 
GeneralRe: How can I change this event handler? Pin
turbosupramk328-Aug-12 15:52
turbosupramk328-Aug-12 15:52 
GeneralRe: How can I change this event handler? Pin
Richard Andrew x6428-Aug-12 15:58
professionalRichard Andrew x6428-Aug-12 15:58 
GeneralRe: How can I change this event handler? Pin
turbosupramk328-Aug-12 16:04
turbosupramk328-Aug-12 16:04 
GeneralRe: How can I change this event handler? Pin
Richard Andrew x6428-Aug-12 16:08
professionalRichard Andrew x6428-Aug-12 16:08 
GeneralRe: How can I change this event handler? Pin
turbosupramk328-Aug-12 16:15
turbosupramk328-Aug-12 16:15 
AnswerRe: How can I change this event handler? Pin
Richard Andrew x6428-Aug-12 16:28
professionalRichard Andrew x6428-Aug-12 16:28 
GeneralRe: How can I change this event handler? Pin
turbosupramk328-Aug-12 16:47
turbosupramk328-Aug-12 16:47 
AnswerRe: How can I change this event handler? Pin
Richard Andrew x6428-Aug-12 16:55
professionalRichard Andrew x6428-Aug-12 16:55 
GeneralRe: How can I change this event handler? Pin
turbosupramk329-Aug-12 4:29
turbosupramk329-Aug-12 4:29 
AnswerRe: How can I change this event handler? Pin
BobJanova28-Aug-12 23:14
BobJanova28-Aug-12 23:14 
GeneralRe: How can I change this event handler? Pin
turbosupramk329-Aug-12 4:28
turbosupramk329-Aug-12 4:28 
GeneralRe: How can I change this event handler? Pin
BobJanova29-Aug-12 4:51
BobJanova29-Aug-12 4:51 

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.