Friday, 15 January 2010

.net - Native selectable auto-sized label in Windows Forms -


Is there any selectable (i.e. I can copy text from labels), auto size in original window forms automatically Label control?

Note that the transparent one text box works well for the selection capability, but not for the part of the automatic size.

You have to measure yourself, and add a bit buffer to make it less irritable:

  textbox1. Minimum size = new size (16, text box 1. Height); Textbox1.TextChanged + = textbox1_Text changed; Zero Text Box 1 Tag (Object Sender, EventArgs e) {int textWidth = TextRenderer.MeasureText (textbox1.Text, textbox1.font, Size.Empty, TextFormatFlags.TextBoxControl) .Width; Textbox1.Width = textWidth + 8; }  

As far as the label is concerned, they only attract text, so there is no selectable functionality as if you get a text box control.


No comments:

Post a Comment