Link to home
Start Free TrialLog in
Avatar of teamjager
teamjager

asked on

C# Is it possible to make the text in a label selectable to the clipboard?

Is it possible to select the text with a mouse within a label and then right click and copy it to a clipboard? I read somewhere else ( Granted this was VB .NET and not C#) that you set Locked = true and Style = Flat and that would allow you to do it. Since the C# label does not have a direct Style property i tired this with the flatstyle property instead. Thanks for the help folks
ASKER CERTIFIED SOLUTION
Avatar of Yurich
Yurich
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Headspace
Headspace

i agree with Yurich; it isn't possible in the common terms of selecting and copying.  to add to Yurich's possible solutions, you could also use a textbox, dimensioned to fit the text exactly, and then set borderstyle = flat, and probably backcolor= control to get a 'label lookalike' that allows selection and copy.  of course, you'd have to disable the ability to type or paste into the textbox without setting enabled = false.

wil
...with ReadOnly to True (using the TextBox)
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;

have a look at the url http://i.stack.imgur.com/1M4wH.png