Solved

How to draw a top line on a panel.

Posted on 2011-09-28
4
276 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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

12 Experts available now in Live!

Get 1:1 Help Now