Is it possible to highlight/select part of text in a Windows Form label control? I know its possible with RTFtextbox control but that using that control would be overkill as I need to create many instances of the label.
Windows. Forms namespace. Add a Label control to the form - Click Label in the Toolbox and drag it over the forms Designer and drop it in the desired location. If you want to change the display text of the Label, you have to set a new text to the Text property of Label.
In Windows Forms, Label control is used to display text on the form and it does not take part in user input or in mouse or keyboard events. The Label is a class and it is defined under System.Windows.Forms namespace.
To print text In Visual Studio, double-click the form you want to print from, in the Solution Explorer pane. This opens the Visual Designer. From the Toolbox, double-click the PrintDocument component to add it to the form. This should create a PrintDocument component with the name printDocument1 .
Is it possible to select text on a Windows form label? - NO (At least no easy way without overriding Label.Paint method)
You can easily change a TextBox for this purpose.
TextBox1.Text = "Hello, Select Me"; TextBox1.ReadOnly = true; TextBox1.BorderStyle = 0; TextBox1.BackColor = this.BackColor; TextBox1.TabStop = false; TextBox1.Multiline = True; // If needed
Don't believe? here is an example for you.
Option 2 (If you just want to enable copy label text)
Double clicking on the label copies the text to clipboard. This is the default winforms Label functionality. You can add a toolTip control to improve the usability if you like.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With