반응형
private DataGridView dataGridView1 = new DataGridView();
private void AddColorColumn()
{
DataGridViewComboBoxColumn comboBoxColumn =
new DataGridViewComboBoxColumn();
comboBoxColumn.Items.AddRange(
Color.Red, Color.Yellow, Color.Green, Color.Blue);
comboBoxColumn.ValueType = typeof(Color);
dataGridView1.Columns.Add(comboBoxColumn);
dataGridView1.EditingControlShowing +=
new DataGridViewEditingControlShowingEventHandler(
dataGridView1_EditingControlShowing);
}
private void dataGridView1_EditingControlShowing(object sender,
DataGridViewEditingControlShowingEventArgs e)
{
((ComboBox)e.Control).SelectedIndexChanged +=
new EventHandler(ComboBox_SelectedIndexChanged);
}
private void ComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
((ComboBox)sender).BackColor = (Color)((ComboBox)sender).SelectedItem;
}
반응형
'프로그래밍' 카테고리의 다른 글
[C#] DataGridView Checkbox Event (0) | 2011.10.29 |
---|---|
[C#] DataGridView Combobox 사용시 BackColor가 검정색으로 변경되는 문제 (0) | 2011.10.27 |
[Asp.net] Json / JQuery (Ajax)/ Asp.net 3가지를 연동하여 데이터 가져오기 (0) | 2011.10.21 |
언어별 JSON 참조 Sample 코드 (0) | 2011.10.21 |
[Asp.net] UpdatePanel 사용 [Ajax사용 / Postback막기] (0) | 2011.09.27 |
댓글