Repository navigation
Expand file tree
/
Copy pathTextBoxWithLabel.cs
More file actions
88 lines (66 loc) · 1.79 KB
/
Copy pathTextBoxWithLabel.cs
File metadata and controls
88 lines (66 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
public partial class TextBoxWithLabel : UserControl
{
public TextBoxWithLabel()
{
InitializeComponent();
}
public string Title {
set {
//mLableLeastWidth = (int)label1.CreateGraphics().MeasureString(value, label1.Font).Width + 5;
label1.Text = value;
}
get {
return label1.Text;
}
}
public string Content {
get {
return textBox1.Text;
}
set {
textBox1.Text = value;
}
}
public TextBox TxBox {
get {
return textBox1;
}
}
int _lableAndTextBoxGap = 5;
public int LableAndTextBoxGap {
get {
return _lableAndTextBoxGap;
}set {
_lableAndTextBoxGap = value;
Invalidate();
}
}
protected override void OnPaint(PaintEventArgs e)
{
this.SuspendLayout();
textBox1.SuspendLayout();
label1.SuspendLayout();
Rectangle rect = label1.ClientRectangle;
int left = rect.Width + _lableAndTextBoxGap;
textBox1.SetBounds(left, 0, Width - left, textBox1.Height);
label1.ResumeLayout();
textBox1.ResumeLayout();
this.ResumeLayout();
System.Diagnostics.Trace.WriteLine("mmmm = ");
base.OnPaint(e);
}
//protected override void OnLoad(EventArgs e)
//{
// base.OnLoad(e);
// textBox1.Width = this.Width - label1.Width;
//}
}