In this article I will explain with an example, how to add (insert) Please Select Option (Item) in ComboBox (DropDownList) in Windows Forms Application using C# and VB.Net.
First a DataTable will be populated from database and then the Please Select Option (Item) will be added to it, finally the ComboBox will be populated from DataTable in Windows Forms Application using C# and VB.Net.
I have made use of the following table Customers with the schema as follows.
I have already inserted few records in the table.
Note: You can download the database table SQL by clicking the download link below.
The Form consists of a ComboBox control and a Button. The Button has been assigned Click event handler.
You will need to import the following namespaces.
Add Please Select option in ComboBox
Inside the Form Load event, the records from the database are fetched into a DataTable.
Once the DataTable is populated from database, a new row is inserted in First position which will act as the Default (Blank) item for the ComboBox.
private void Form1_Load(object sender, EventArgs e)
string constr = @"Data Source=.\SQL2014;Initial Catalog=AjaxSamples;Integrated Security=true";
using (SqlConnection con = new SqlConnection(constr))
using (SqlDataAdapter sda = new SqlDataAdapter("SELECT CustomerId, Name FROM Customers", con))
//Fill the DataTable with records from Table.
DataTable dt = new DataTable();
//Insert the Default Item to DataTable.
DataRow row = dt.NewRow();
row = 0;
row = "Please select";
//Assign DataTable as DataSource.
cbCustomers.DataSource = dt;
cbCustomers.DisplayMember = "Name";
cbCustomers.ValueMember = "CustomerId";
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Dim constr As String = "Data Source=.\SQL2014;Initial Catalog=AjaxSamples;Integrated Security=true"
Using con As SqlConnection = New SqlConnection(constr)
Using sda As SqlDataAdapter = New SqlDataAdapter("SELECT CustomerId, Name FROM Customers", con)
'Fill the DataTable with records from Table.
Dim dt As DataTable = New DataTable()
'Insert the Default Item to DataTable.
Dim row As DataRow = dt.NewRow()
row(0) = 0
row(1) = "Please select"
'Assign DataTable as DataSource.
cbCustomers.DataSource = dt
cbCustomers.DisplayMember = "Name"
cbCustomers.ValueMember = "CustomerId"
Fetching the selected Text and Value of ComboBox
When the Button is clicked, the Selected Text and Value of the ComboBox is fetched and displayed using MessageBox.
private void btnSubmit_Click(object sender, EventArgs e)
string message = "Name: " + cbCustomers.Text;
message += Environment.NewLine;
message += "CustomerId: " + cbCustomers.SelectedValue;
Private Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSubmit.Click
Dim message As String = "Name: " & cbCustomers.Text
message += Environment.NewLine
message += "CustomerId: " & cbCustomers.SelectedValue