How to specify a color for drawing

Hi,

I want the pensile not be blue but: 194;196;203
How can I do that?

Peter
private void pnlCreation_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.DrawLine(Pens.Blue, this.ClientRectangle.Left, 
            this.ClientRectangle.Top, this.ClientRectangle.Width, 
            this.ClientRectangle.Top);
        }

Open in new window

LVL 1
peterkiersAsked:
Who is Participating?
 
Kiran SonawaneConnect With a Mentor Project LeadCommented:
This is correct way

Color your_color = Color.FromArgb(194, 196, 203);
    Pen your_pen = new Pen(your_color, penWidth);
   e.Graphics.DrawLine(your_pen, this.ClientRectangle.Left,
            this.ClientRectangle.Top, this.ClientRectangle.Width,
            this.ClientRectangle.Top);
0
 
Kiran SonawaneProject LeadCommented:
You can do like this

Color your_color = Color.FromArgb(194, 196, 203);

e.Graphics.DrawLine(your_color, this.ClientRectangle.Left,
            this.ClientRectangle.Top, this.ClientRectangle.Width,
            this.ClientRectangle.Top);
0
 
jppintoCommented:
e.Graphics.DrawLine(Color.FromArgb(194,196,203)), this.ClientRectangle.Left,
            this.ClientRectangle.Top, this.ClientRectangle.Width,
            this.ClientRectangle.Top);
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
peterkiersAuthor Commented:
       private void pnlCreation_Paint(object sender, PaintEventArgs e)
        {
            Color your_color = Color.FromArgb(194, 196, 203);
            e.Graphics.DrawLine(your_color, this.ClientRectangle.Left,
            this.ClientRectangle.Top, this.ClientRectangle.Width,
            this.ClientRectangle.Top);
        }

Error:
cannot convert from 'System.Drawing.Color' to 'System.Drawing.Pen'
0
 
Kiran SonawaneProject LeadCommented:
Check with my correct earlier answer
0
 
jppintoCommented:
Did you checked with mine?
0
 
peterkiersAuthor Commented:
jppinto had alot of errors and sonawanekiran's code works great.

Peter
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.