![]() |
Sylloge
A C# helper library
|
00001 using System; 00002 using System.Collections.Generic; 00003 using System.ComponentModel; 00004 using System.Drawing; 00005 using System.Data; 00006 using System.Text; 00007 using System.Windows.Forms; 00008 00009 namespace Sylloge.Controls 00010 { 00011 public partial class LabeledTextBox : UserControl 00012 { 00013 private delegate void StringDelegate(string v); 00014 00015 public LabeledTextBox() 00016 { 00017 this.InitializeComponent(); 00018 00019 } 00020 00021 public new BorderStyle BorderStyle 00022 { 00023 get { return this.c_TextBox.BorderStyle; } 00024 set { this.c_TextBox.BorderStyle = value; } 00025 } 00026 00027 public string Label 00028 { 00029 get { return this.c_Label.Text; } 00030 set { this.SetLabel(value); } 00031 } 00032 00033 public ContentAlignment LabelAlignment 00034 { 00035 get 00036 { 00037 return this.c_Label.TextAlign; 00038 } 00039 set 00040 { 00041 this.c_Label.TextAlign = value; 00042 } 00043 } 00044 00045 public override string Text 00046 { 00047 get { return this.c_TextBox.Text; } 00048 set { this.SetValue(value); } 00049 } 00050 00051 private void SetLabel(string l) 00052 { 00053 if (this.c_Label.InvokeRequired) { 00054 this.c_Label.Invoke(new StringDelegate(this.SetLabel), l); 00055 } else { 00056 this.c_Label.Text = l; 00057 } 00058 } 00059 00060 private void SetValue(string v) 00061 { 00062 if (this.c_TextBox.InvokeRequired) { 00063 this.c_TextBox.Invoke(new StringDelegate(this.SetValue), v); 00064 } else { 00065 this.c_TextBox.Text = v; 00066 } 00067 } 00068 } 00069 }