Hi frds,
I am presently working on Windows app...
can any body suggest me how to load combo box in dynamic datagridView and suggest me how to implement events on combo control............
Any help is appreciated
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
kiran kumarRank #3,110 · 461 reputationPosted Feb 22, 2010, 6:57 AM EST
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace combogrid
{
public partial class Form1 : Form
{
DataGridView dv = new DataGridView();
DataGridViewComboBoxColumn cb = new DataGridViewComboBoxColumn();
string[] com = {"hi","hello" };
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.cb.HeaderText = "dynamic";
this.dv.Columns.Add(cb);
for (int i = 0; i < com.Length; i++)
{
this.cb.Items.Add(com[i]);
}
this.dv.Location = new Point(75, 74);
this.Controls.Add(dv);
dv.EditingControlShowing+=new DataGridViewEditingControlShowingEventHandler(dv_EditingControlShowing);
}
private void dv_EditingControlShowing(object sender,
DataGridViewEditingControlShowingEventArgs e)
{
ComboBox combo = e.Control as ComboBox;
if (combo != null)
{
combo.SelectedIndexChanged +=
new EventHandler(ComboBox_SelectedIndexChanged);
}
}
private void ComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
this.cb.HeaderText = "event";
}
}
}
ACCEPT THE ANSWER IF IT HELPS YOU JUST CLICK ON THE ACCEPTED ANSWER CHECKBOX
paul daniel189 reputationPosted Feb 22, 2010, 11:35 PM EST
http://rustemsoft.com/datagridview_columns1.htm