Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 289
  • Last Modified:

How to draw a top line on a panel.

Hi,

I would like to draw a line on the top edge of a panel.
I quess I need the onpain-event of the panel for that.
But I don't know how! And the line must have the color
"#c2c4cb".

Who knows the answer and is willing to help me?

Greetings, Peter Kiers
0
peterkiers
Asked:
peterkiers
  • 2
  • 2
1 Solution
 
James AtkinSenior Principle Software EngineerCommented:
You need to add the Paint Event to the Panel using the Events Tab in its Properties

Then just add something like this in the Paint Handler...

        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            Pen p = new Pen(new SolidBrush(Color.FromArgb(0xC2, 0xC4, 0xCB)));
            e.Graphics.DrawLine(p, 1, 1, 100, 1);
        }

Hope this helps...
0
 
peterkiersAuthor Commented:
It does not draw the whole line on the top edge of the panel.

Peter
0
 
peterkiersAuthor Commented:
I have change:

e.Graphics.Drawline(p, 1, 1, 176, 1);

Now the line is as wide a the panel width.

But when I resize the panel the line stays the same!!!
0
 
James AtkinSenior Principle Software EngineerCommented:
Just change the "176" to panel1.width
or whatever your panel is called
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.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now