0% found this document useful (0 votes)
4 views2 pages

C# Controls TextBox, ComboBox

The document provides an overview of the ComboBox and TextBox controls in C# Windows Forms, including code examples for creating and populating these controls. It also outlines a task to create a Windows Forms application that displays user input from a TextBox in a MessageBox upon button click. The provided code demonstrates the implementation of this functionality in a simple form application.

Uploaded by

Naseeb LashaRi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

C# Controls TextBox, ComboBox

The document provides an overview of the ComboBox and TextBox controls in C# Windows Forms, including code examples for creating and populating these controls. It also outlines a task to create a Windows Forms application that displays user input from a TextBox in a MessageBox upon button click. The provided code demonstrates the implementation of this functionality in a simple form application.

Uploaded by

Naseeb LashaRi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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]);
}
}
}

You might also like