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
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

no, i don't think you can do it with the label... what you can do is:

1. add a ContextMenu to your project
2. add one menu item to the menu above and set the text to Copy
3. add this menu as a context menu of your label (say label1)
4. double click the "Copy" menu item and add the following line:

          Clipboard.SetDataObject( label1.Text, true );

Now it will copy any text from your label and will paste it anywhere else (like in some word document or text document) with the Paste command or Ctrl+V

Good luck,

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.

...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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.