日期:2014-05-17 浏览次数:21161 次
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
//列的索引根据自己的网格来
if (dataGridView1.CurrentCell.RowIndex != -1 && dataGridView1.CurrentCell.ColumnIndex == 0)
{
//还原控件并绑定事件
((ComboBox)e.Control).SelectedIndexChanged += new EventHandler(Form1_SelectedIndexChanged);
}
}
//自定义事件
private void Form1_SelectedIndexChanged(object sender, EventArgs e)
{
MessageBox.Show(((ComboBox)sender).SelectedIndex.ToString());
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
//这事件不可以吗? winform的combobox没有value值的吧 只有text属性和index
textbox1.Text = combobox1.Text;
textbox1.Text = comboBox2.SelectedText;
}