Solved

How to draw a top line on a panel.

Posted on 2011-09-28
4
275 Views
Last Modified: 2013-12-17
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
Comment
Question by:peterkiers
  • 2
  • 2
4 Comments
 
LVL 4

Expert Comment

by:jatkin
ID: 36716158
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
 
LVL 1

Author Comment

by:peterkiers
ID: 36716191
It does not draw the whole line on the top edge of the panel.

Peter
0
 
LVL 1

Author Comment

by:peterkiers
ID: 36716215
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
 
LVL 4

Accepted Solution

by:
jatkin earned 500 total points
ID: 36716221
Just change the "176" to panel1.width
or whatever your panel is called
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now