C# Notes
ComboBox Control
A ComboBox is a Windows Forms control that provides a drop-down list from
which the user can select one item, or type a new value.
Code to fill ComboBox through code:
ComboBox cmb = new ComboBox();
[Link] = new [Link](20, 60);
[Link]("C#");
[Link]("Java");
[Link]("Python");
[Link](cmb);
TextBox control
A TextBox is a Windows Forms control used to accept input from the user in text
form. It allows the user to enter, edit, and display text such as names, numbers, or
messages.
Code to create TextBox:
TextBox txt = new TextBox();
[Link] = "txtName";
[Link] = "Enter Name";
[Link] = 150;
[Link] = new [Link](20, 20);
[Link](txt);
TASKT
Create a C# Windows Forms application in which a form contains one TextBox and
one [Link] the user enters text in the TextBox and clicks the Button, the
entered value should be displayed on the form as a dialog box (MessageBox).
using System;
using [Link];
namespace MessageBoxDemo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
[Link]([Link]);
}
}
}