Follow up on that label/line control…

It seems a few people had questions about the control I posted previously, so here are answers to two of the questions that people might be running into:

  1. What about word wrapping? Good point, turns out I hadn’t quite finished my code before I got distracted by food or coffee… and then I ended up leaving out word wrapping! You just need to modify 1 line to make wrapping work, though:

    g.DrawString(Me.Text, f, b, 0, 0, sf)


    g.DrawString(Me.Text, f, b, labelBounds, sf)

    and you should be set.

  2. I put the control on the form and I get nothing… no line, just text… what’s up? The control draws a line between the end of your text (.Spacing past the end actually) and the right-most edge of the control. So… to make it work, you need to turn AutoSize off (AutoSize = False) and stretch the right edge of the control out to where you want the line to end. That should do it!

Hope these little “tips” help anyone who wants to try out this control!

Author: Duncan Mackenzie

I'm the Developer Lead for the Channel 9 team, formerly worked on MSDN as a developer, content strategist and author.

2 thoughts on “Follow up on that label/line control…”

  1. I changed the code in (1) and checked AutoSize in (2). It was already set to False and I had the control stretched out well past the text, but I’m still not seeing the line…I must be missing something obvious.

  2. Thanks for the offer to look at my code, but I finally figured it out. The code was fine. But the FlatStyle on my DividerLabel control was set to System, and I discovered changing the FlatStyle to Standard made the line appear.

Leave a Reply