---
title: "combobox in datagridview"  
description: "private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)                ComboBox editingComboBox"  
author: "imran pathan"  
published: 2014-02-09  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/644/combobox-in-datagridview  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# combobox in datagridview

[private](https://www.mindstick.com/blog/11097/java-access-modifiers-the-public-and-the-private-modifiers) void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)\
{\
[ComboBox](https://www.mindstick.com/articles/57/display-record-according-to-combobox-selection-in-csharp-dot-net) editingComboBox = (ComboBox)e.Control;\
if (editingComboBox != [null](https://www.mindstick.com/forum/33922/how-to-use-null-coalescing-operator-in-c-sharp))\
editingComboBox.SelectedIndexChanged += new System.EventHandler(this.editingComboBox_SelectedIndexChanged);\
}\
private void editingComboBox_SelectedIndexChanged(object sender, System.EventArgs e)\
{\
ComboBox comboBox1 = (ComboBox)sender;\
// Display [index](https://www.mindstick.com/blog/198/index-in-sql-server)\
//MessageBox.Show(comboBox1.SelectedIndex.ToString());\
// Display [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages)\
[SqlDataAdapter](https://www.mindstick.com/interview/33991/what-is-sqldataadapter) adp = new SqlDataAdapter("[select](https://www.mindstick.com/forum/160534/orderby-then-select-vs-select-then-orderby-performance) edd from cdl where id='" + comboBox1.SelectedValue.ToString() + "'", con);\
[DataTable](https://www.mindstick.com/blog/195/datatable-in-ado-dot-net) dt = new DataTable();\
adp.Fill(dt); \
\
for (int i = 0; i < dt.Rows.Count; i++)\
{\
ED.DataSource = dt;\
ED.DisplayMember = dt.Rows[i]["edd"].ToString();\
ED.ValueMember = dt.Rows[i]["edd"].ToString();\
\
}\
\
}\
//MessageBox.Show(comboBox1.Text);\
\
I am [writing](https://www.mindstick.com/articles/12997/5-essential-tips-on-resume-writing-for-business-analysts) this code but doesnot work wats [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) pls help me...@@

---

Original Source: https://www.mindstick.com/blog/644/combobox-in-datagridview

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
