Get Name of Multiple TextBoxes Control in C#
Submitted by donbermoy on Wednesday, July 16, 2014 - 21:49.
This is a simple tutorial in which we are going to get all the name of multiple textboxes in C# using a loop.
So, now let's start this tutorial!
1. Let's start with creating a Windows Form Application in C# for this tutorial by following the following steps in Microsoft Visual Studio 2010: Go to File, click New Project, and choose Windows Application.
2. Drag any textbox that you want and only one Button. You must design your interface like this:
3. Put this code in your button1_click. This will trigger to show the names of the textboxes that you have dragged.
Output:
For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.
Best Regards,
Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
If you have some queries, feel free to contact the number or e-mail below.
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]
Add and Follow me on Facebook: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware
- private void Button1_Click(System.Object sender, System.EventArgs e)
- {
- //create a variable that represents the control.
- Control txt = default(Control);
- //After that, Loop the control that you have created.
- foreach (Control tempLoopVar_txt in this.Controls)
- {
- //Then, check if the type of the control is a Textbox and if it’s true, then perform the process that puts the name of the TextBox to itself. Do this code inside the Loop.
- txt = tempLoopVar_txt;
- {
- txt.Text = txt.Name;
- }
- }
- }
Add new comment
- 73 views