Filed under: General, Programming, .NET — Oliver Sturm @ 11:07 am - 3 years, 1 month ago
Just saw this post in a newsgroup about how to show the horizontal lines that Microsoft likes to use in their dialogs. A lot of people replied with ideas of using other controls, like panels, to achieve the desired effect - to me, a much simpler and more effective idea is to just create a control myself.
So, the specific style described by the OP seems to be this:
This is what you get by using a label set to a height of 2 and with a BorderStyle of Fixed3D. The OP said explicitely that this was what he wanted, which I find curious because the lines in my Word Options dialog, for instance, look quite different:
So, to account for both needs, I included the etched border as well as the single line border in my sample. I’m sure there are millions of other line styles out there, but these should be simple to include once the framework is there. Here’s the control source code:
This was done in VS 2005 beta 2. You might have to make minor changes for .NET 1 if needed - I’m not 100% sure about the flags in the SetStyle call, look them up if you need to.
The lines I was looking at can be seen at the bottom of the dialog in Visual C# Express here:
http://dantup.me.uk/tmp/line.jpg
Your solution is certainly more elegant than the Label! I’ll add it to my project!
Comment by Danny Tuppeny — 6/10/2005 @ 5:40 pm - 3 years, 1 month ago