In this tutorial, i’ll show you how To Display Content of Textbox on a Label Using Button in C#.
Now design this form with the label, text box and button controls.
Form Design:
C# Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void btnShow_Click(object sender, EventArgs e) { lblResult.Text ="First Name: "+txtFirstName.Text+"\nLast Name: "+txtLastName.Text; } private void btnClear_Click(object sender, EventArgs e) { txtFirstName.Clear(); txtLastName.Clear(); lblResult.Text = ""; } } |
Output: