?
Solved

How to specify a color for drawing

Posted on 2011-10-14
7
Medium Priority
?
172 Views
Last Modified: 2013-12-16
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

0
Comment
Question by:peterkiers
  • 3
  • 2
  • 2
7 Comments
 
LVL 17

Expert Comment

by:sonawanekiran
ID: 36967259
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
 
LVL 33

Expert Comment

by:jppinto
ID: 36967264
e.Graphics.DrawLine(Color.FromArgb(194,196,203)), this.ClientRectangle.Left,
            this.ClientRectangle.Top, this.ClientRectangle.Width,
            this.ClientRectangle.Top);
0
 
LVL 17

Accepted Solution

by:
sonawanekiran earned 2000 total points
ID: 36967265
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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
LVL 1

Author Comment

by:peterkiers
ID: 36967267
       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
 
LVL 17

Expert Comment

by:sonawanekiran
ID: 36967270
Check with my correct earlier answer
0
 
LVL 33

Expert Comment

by:jppinto
ID: 36967272
Did you checked with mine?
0
 
LVL 1

Author Comment

by:peterkiers
ID: 36967282
jppinto had alot of errors and sonawanekiran's code works great.

Peter
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Integration Management Part 2
Suggested Courses
Course of the Month16 days, 9 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question