本文介绍了Datagridview combobox coloum的价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个datagridveiw组合框,其中有一些值.我正在尝试捕获用户单击的内容.我尝试了CellValueChanged,CellContentClicked等,但没有任何效果.
我想将此值存储到变量(重要)中,然后在用户选择值后将光标移到列".
请帮忙.还请告知发生什么事件.
感谢
Hi,
I have a datagridveiw combo box with a few values in there. I am trying to capture what user clicked. I tried CellValueChanged, CellContentClicked etc. but nothing works.
I want to store this value to a variable (important) and then shift the cursor to Column after user has selected value.
Please help. Please also advise what event to fire.
Thanks
推荐答案
dataGridView1.Rows["YourRowNumber"].Cells["YourColumnNameOrNumber"].Value;
它将正确获取选定的值.
It fetches the selected value properly.
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
try
{
if (this.dataGridView.CurrentCell.ColumnIndex == (int)Column.Col)
{
ComboBox comboBox = e.Control as ComboBox;
if (comboBox != null)
{
comboBox.SelectedIndexChanged += new EventHandler(ComboBoxIndexChanged);
}
}
return;
}
}
private void ComboBoxIndexChanged(object sender, EventArgs e)
{
dataGridView1.Rows["YourRowNumber"].Cells["YourColumnNameOrNumber"].Value;
}
这篇关于Datagridview combobox coloum的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!