Hi,
How do i Dynamically add a comboBox column to a a data grid view column?
TY
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Kirtan PatelRank #292 · 8.6K reputationPosted Oct 21, 2009, 1:05 AM EDT
Friend,Here is Code for it
please check "do you like this answer" :)
DataGridViewComboBoxCell cell = new DataGridViewComboBoxCell();
cell.Items.Add("Test");
cell.Items.Add("Test2");
DataGridViewColumn clm = new DataGridViewColumn(cell);
dataGridView1.Columns.Add(clm);
naura paxRank #2,843 · 502 reputationPosted Oct 21, 2009, 1:02 AM EDT
here is one example
DataGridViewComboBoxColumn col = new DataGridViewComboBoxColumn(); col.Name = "cmbLedger"; grd.Columns.Add(col); DataSet ds=GetDataSourceFunction(); ((DataGridViewComboBoxColumn)grd.Columns["cmbLedger"]).DataSource = ds;((DataGridViewComboBoxColumn)grd.Columns["cmbLedger"]).DisplayMember = "LedgerName";((DataGridViewComboBoxColumn)grd.Columns["cmbLedger"]).ValueMember = "LedgerID";you can write this in form load.
jingeRank #2,527 · 554 reputationPosted Oct 21, 2009, 2:22 AM EDT
The above looks even better.