You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: dotnet-desktop-guide/net/winforms/controls-design/how-to-create-usercontrol.md
+44-37
Original file line number
Diff line number
Diff line change
@@ -46,36 +46,40 @@ The user control is made up of _constituent controls_, which are the controls yo
46
46
47
47
01. With the designer open, the user control design surface should be the selected object. If it's not, click on the design surface to select it. Set the following properties in the **Properties** window:
48
48
49
-
| Property | Value |
50
-
|-------------|------------|
51
-
| MinimumSize |`84, 53`|
52
-
| Size |`191, 53`|
49
+
> [!div class="mx-tableNormal"]
50
+
> | Property | Value |
51
+
> |-------------|------------|
52
+
> | MinimumSize |`84, 53`|
53
+
> | Size |`191, 53`|
53
54
54
55
01. Add a **Label** control. Set the following properties:
55
56
56
-
| Property | Value |
57
-
|----------|------------|
58
-
| Name |`lblTitle`|
59
-
| Location |`3, 5`|
57
+
> [!div class="mx-tableNormal"]
58
+
> | Property | Value |
59
+
> |----------|------------|
60
+
> | Name |`lblTitle`|
61
+
> | Location |`3, 5`|
60
62
61
63
01. Add a **TextBox** control. Set the following properties:
62
64
63
-
| Property | Value |
64
-
|----------|------------|
65
-
| Name |`txtValue`|
66
-
| Anchor |`Top, Left, Right`|
67
-
| Location |`3, 23`|
68
-
| Size |`148, 23`|
65
+
> [!div class="mx-tableNormal"]
66
+
> | Property | Value |
67
+
> |----------|------------|
68
+
> | Name |`txtValue`|
69
+
> | Anchor |`Top, Left, Right`|
70
+
> | Location |`3, 23`|
71
+
> | Size |`148, 23`|
69
72
70
73
01. Add a **Button** control. Set the following properties:
71
74
72
-
| Property | Value |
73
-
|----------|------------|
74
-
| Name |`btnClear`|
75
-
| Anchor |`Top, Right`|
76
-
| Location |`157, 23`|
77
-
| Size |`31, 23`|
78
-
| Text |`↻`|
75
+
> [!div class="mx-tableNormal"]
76
+
> | Property | Value |
77
+
> |----------|------------|
78
+
> | Name |`btnClear`|
79
+
> | Anchor |`Top, Right`|
80
+
> | Location |`157, 23`|
81
+
> | Size |`31, 23`|
82
+
> | Text |`↻`|
79
83
80
84
The control should look like the following image:
81
85
@@ -127,28 +131,31 @@ If you created a new project in the last section, you have a blank Form named **
127
131
01. Move back to the designer and separate the controls so that you can see both of them.
128
132
01. Select one control and set the following properties:
129
133
130
-
| Property | Value |
131
-
|----------|----------------|
132
-
| Name |`ctlFirstName`|
133
-
| Location |`12, 12`|
134
-
| Size |`191, 53`|
135
-
| Title |`First Name`|
134
+
> [!div class="mx-tableNormal"]
135
+
> | Property | Value |
136
+
> |----------|----------------|
137
+
> | Name |`ctlFirstName`|
138
+
> | Location |`12, 12`|
139
+
> | Size |`191, 53`|
140
+
> | Title |`First Name`|
136
141
137
142
01. Select the other control and set the following properties:
138
143
139
-
| Property | Value |
140
-
|----------|---------------|
141
-
| Name |`ctlLastName`|
142
-
| Location |`12, 71`|
143
-
| Size |`191, 53`|
144
-
| Title |`Last Name`|
144
+
> [!div class="mx-tableNormal"]
145
+
> | Property | Value |
146
+
> |----------|---------------|
147
+
> | Name |`ctlLastName`|
148
+
> | Location |`12, 71`|
149
+
> | Size |`191, 53`|
150
+
> | Title |`Last Name`|
145
151
146
152
01. Back in the **Toolbox** window, add a label control to the form, and set the following properties:
147
153
148
-
| Property | Value |
149
-
|----------|---------------|
150
-
| Name |`lblFullName`|
151
-
| Location |`12, 252`|
154
+
> [!div class="mx-tableNormal"]
155
+
> | Property | Value |
156
+
> |----------|---------------|
157
+
> | Name |`lblFullName`|
158
+
> | Location |`12, 252`|
152
159
153
160
01. Next, you need to generate the event handlers for the two user controls. In the designer, double-click on the `ctlFirstName` control. This action generates the event handler for the `TextChanged` event, and opens the code editor.
154
161
01. Swap back to the designer and double-click the `ctlLastName` control to generate the second event handler.
0 commit comments