C # A Label control with a scrollbar, or a little blinking when selected with the mouse:
Namespace Label control with scroll bar {public class TextBoxLabel:System.Windows.Forms.TextBox {[DllImport ("User32", Entry Point = "HideCaret")] private static extern bool HideCaret (IntPtr hWnd); [DllImport ("user32", EntryPoint = "ShowCaret")] private static extern bool ShowCaret (IntPtr hWnd); Public Textboxlabel (): Base () {this. TabStop = false; This. SetStyle (controlstyles.selectable, false); This. Cursor = Cursors.Default; This. ReadOnly = true; This. shortcutsenabled = false; This. HideSelection = true; This. GotFocus + = new EventHandler (textboxlabel_gotfocus); This. MouseMove + = new MouseEventHandler (textboxlabel_mousemove); } private void Textboxlabel_gotfocus (Object sender, System.EventArgs e) {if (ShowCaret ((TextBox) sender) . Handle)) {HideCaret ((TextBox) sender). Handle); }} private void Textboxlabel_mousemove(Object sender, MouseEventArgs e) {if ((TextBox) sender). Selectedtext.length > 0) {(TextBox) sender. selectionlength = 0; } } }}
Effect:
Realization idea and use reference: http://bbs.csdn.net/topics/390632325?page=1#post-398542672
C # Label control with scroll bars