We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

horizontal line in c# forms

Dodger42
Dodger42 asked
on
Medium Priority
3,143 Views
Last Modified: 2012-06-27
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.

Suggestions?

Thanks.
Comment
Watch Question

Commented:
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, Digital Design, and Mathematics Teacher
CERTIFIED EXPERT
Top Expert 2009
Commented:
You can use a Label with a Height of 1 and the BorderStyle set to FixedSingle.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

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.

Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
CERTIFIED EXPERT
Top Expert 2009

Commented:
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!

Sorry...
Commented:
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)
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
You can draw lines in the Paint event using GDI+, but that may be just as "clunky".

Bob

Author

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, Digital Design, and Mathematics Teacher
CERTIFIED EXPERT
Top Expert 2009

Commented:
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
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.