Attach combo box inside Datagridview on CellClick of Datagridview.
Step 1: Add Window form and drag and drop Datagridview from tool box into form.

Step 2: Create data for binding Datagridview and combo boxes.
Suppose in our case, we need two combo boxes, “Description” and “PaidWith”
So we need three data tables, one for the “Description” combo box, the second for “PaidWith” combobox, and we need a third table for binding Datagridview.
- /// <summary>
- /// Get datatable of description.
- /// </summary>
- /// <returns></returns>
- private DataTable GetDescriptionTable()
- {
- DataTable l_dtDescription = new DataTable();
- l_dtDescription.Columns.Add("Description", typeof(string));
- l_dtDescription.Columns.Add("Type", typeof(string));
- l_dtDescription.Rows.Add("Lunch", "Expense");
- l_dtDescription.Rows.Add("Dinner", "Expense");
- l_dtDescription.Rows.Add("Breakfast", "Expense");
- l_dtDescription.Rows.Add("Designing", "Service");
- l_dtDescription.Rows.Add("Drawing", "Service");
- l_dtDescription.Rows.Add("Paper", "Material");
- l_dtDescription.Rows.Add("DrawingBoard", "Material");
- return l_dtDescription;
- }
- /// <summary>
- /// Get datatable of PaidWIth.
- /// </summary>
- /// <returns></returns>
- private DataTable GetPaidWithTable()
- {
- DataTable l_dtPaidwith = new DataTable();
- l_dtPaidwith.Columns.Add("PaidWith", typeof(string));
- l_dtPaidwith.Columns.Add("Code", typeof(string));
- l_dtPaidwith.Rows.Add("CreditCard", "CC");
- l_dtPaidwith.Rows.Add("DebitCard", "DC");
- return l_dtPaidwith;
- }
- /// <summary>
- /// Get the data for grid.
- /// </summary>
- /// <returns></returns>
- private DataTable GetGridTable()
- {
- DataTable l_dtGridTable = new DataTable();
- l_dtGridTable.Columns.Add("PaidWith", typeof(string));
- l_dtGridTable.Columns.Add("Description", typeof(string));
- l_dtGridTable.Rows.Add("CreditCard", "Drawing");
- return l_dtGridTable;
- }



Farid AbdiPosted Jan 19, 2021, 1:11 PM
Very good much better than the rubbish you tube videos that came up in Google
Vadivel MurthyPosted Oct 8, 2019, 6:10 AM
Excellent Explanation :)
SubashPosted Sep 11, 2016, 9:35 AM
Good one
Vignesh ManiPosted Jul 20, 2016, 11:15 AM
Nice
kalu singh raoPosted Jul 19, 2016, 7:59 AM
Nice...