• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3127
  • Last Modified:

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.


2 Solutions
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 TomlinsonMiddle School Assistant TeacherCommented:
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.

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Mike TomlinsonMiddle School Assistant TeacherCommented:
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)
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 TomlinsonMiddle School Assistant TeacherCommented:
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
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

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

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