In this article, we will autofill the CustomerNames from CustomerDetails table in a ComboBox on FormLoad event.
Create a CobmoBox say cmbCustomerName on your form.
Write the following code in the FormLoad event of your code.
Use the code for getCustomerDetails() function from https://tutorials4sharepoint.wordpress.com/2017/11/08/get-all-the-data-from-a-table-in-ms-access-database-using-c-ado-net/ post.
DataTable custDt = new DataTable();
custDt = getCustomerDetails();
cmbCustomerName.DataSource = custDt;
if(custDt!=null)
{
cmbCustomerName.BindingContext = this.BindingContext;
cmbCustomerName.DisplayMember = "CustomerName";
cmbCustomerName.ValueMember = "CustomerID";
cmbCustomerName.Text = "-Select Option-";
}
else
cmbCustomerName.Text = "No Customer Data Available!";