Add Values in ComboBox in C#:
cmbCustomerName.Items.Add("Akanksha");
Get the selected item value from combo Box:
string customerName = cmbCustomerName.GetItemText(cmbCustomerName.SelectedItem);
Show current Date and Time:
lbldate.Text=DateTime.Now.ToString();
Connection String to connect Visual Studio C# Windows Form Application to MS Access .accdb Database:
string connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\DailyExpenses.accdb";
Check for zero rows in a DataTable:
if(dataTable==null){......}
Fetch DataTable CellValue into a variable:
txtCustomerID.Text = custDt.Rows[0]["CustomerID"].ToString();
Enter only numbers and Backspace in TextBox:
private void txtCustomerPhone_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = !(char.IsDigit(e.KeyChar) || e.KeyChar == 8);
}