horizontal line in c# forms

Hey all,

A real basic question I presume. I simply want to draw horizontal lines on my forms for formatting and neatness on my GUI.

I got the drawing toolbar up, but it is always greyed out.


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You could draw a picture box and set the background color to black if you want... That's the best thing I can think of right now, but I'll look more into it.
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
You can use a Label with a Height of 1 and the BorderStyle set to FixedSingle.
Dodger42Author Commented:
Thanks IM, that is close, but its quite clunky. Grabbing and dragging the flattened label is akward. Surely there is another way. In vs2005, if you go to options, you can see the sort of horizontal line I mean above the OK, Cancel buttons.

Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
I know it's clunky and a pain in the arse to move around...

Unfortunately there just isn't a plain old line control included in .Net!

You could make your own usercontrol, or you can head over to www.codeproject.com and search for "Line control", where several people has made simple line controls. (you have to be registered there (free) to download source)

This one: http://www.codeproject.com/cs/miscctrl/NiceLine.asp works fine I think, it didn't compile in vs 2005 but it was only one line that had to be changed (add a cast to double)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bob LearnedCommented:
You can draw lines in the Paint event using GDI+, but that may be just as "clunky".

Dodger42Author Commented:
Thanks all. I guess there are several answers which get a solution. I'm shocked given the frequent use of lines in forms, that MS havent included a control even after all these years of forms design.

Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
So am I.  =)

The lowly VB6 had a line control (also a rectangle and ellipse control wrapped in a Shape control) that many people miss after moving to VB.Net
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.