|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
A Label control that its text can be selected with the mouseHi,
Is there a way to allow the Label control to select its text with the mouse by the user? I've looked at the Label's properties but I couldn't find anything making this possible. Am I missing something here? Well, it can be done with a Textbox control, but the problem with this approach is that when I click on a read only Textbox, a vertical line is displayed inside it. In short, I want something similar to internet browsers, where users can select the text and copy it to the clipboard. Thanks for your time, Ben You're have to use the Windows API to do this, hiding and showing the caret
according to TextBox events. See the following: http://www.pinvoke.net/default.aspx/user32/HideCaret.html http://www.pinvoke.net/default.aspx/user32/ShowCaret.html -- Show quoteHide quoteHTH, Kevin Spencer Microsoft MVP Software Composer http://unclechutney.blogspot.com The shortest distance between 2 points is a curve. "Ben" <B**@discussions.microsoft.com> wrote in message news:A62D43EA-4B34-4ABA-92D3-DB429254394A@microsoft.com... > Hi, > > Is there a way to allow the Label control to select its text with the > mouse > by the user? > I've looked at the Label's properties but I couldn't find anything making > this possible. > Am I missing something here? Well, it can be done with a Textbox control, > but the problem with this approach is that when I click on a read only > Textbox, a vertical line is displayed inside it. > In short, I want something similar to internet browsers, where users can > select the text and copy it to the clipboard. > > Thanks for your time, > > Ben Hey Kevin,
Thanks a alot, I'll have a look at that. Ben Show quoteHide quote "Kevin Spencer" wrote: > You're have to use the Windows API to do this, hiding and showing the caret > according to TextBox events. See the following: > > http://www.pinvoke.net/default.aspx/user32/HideCaret.html > http://www.pinvoke.net/default.aspx/user32/ShowCaret.html > > -- > HTH, > > Kevin Spencer > Microsoft MVP > Software Composer > http://unclechutney.blogspot.com > > The shortest distance between 2 points is a curve. > > "Ben" <B**@discussions.microsoft.com> wrote in message > news:A62D43EA-4B34-4ABA-92D3-DB429254394A@microsoft.com... > > Hi, > > > > Is there a way to allow the Label control to select its text with the > > mouse > > by the user? > > I've looked at the Label's properties but I couldn't find anything making > > this possible. > > Am I missing something here? Well, it can be done with a Textbox control, > > but the problem with this approach is that when I click on a read only > > Textbox, a vertical line is displayed inside it. > > In short, I want something similar to internet browsers, where users can > > select the text and copy it to the clipboard. > > > > Thanks for your time, > > > > Ben > > > HideCaret fails, and when i call Marshal.GetLastWin32Error, it
returns a value of 5, which i think means access denied. How can i make this work please? Thanks, Ben >HideCaret fails, and when i call Marshal.GetLastWin32Error, it The declaration at pinvoke.net didn't have SetLastError=true in the>returns a value of 5, which i think means access denied. >How can i make this work please? DllImport attribute. Did you add that? If not, you can't expect GetLastWin32Error to return the right error code. Mattias -- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup.
Other interesting topics
GroupBox and/or Tab Control Font Colours
MDI app - don't load document twice toolstrip container backcolor and gradients - I want it to look like outlook 2003! OT: Crossword Puzzle Creator - .NET Source ClickOnce deployment, include font Need help on some PropertyGrid and PropertyGridView members Displaying a status image in a datagridview Assembly Version problems Drawing special text with gradient colors (Windows Forms VB.NET 1. Generating 3D graphs in .Net 2.0 windows forms. |
|||||||||||||||||||||||