SelectionChangeCommitted

SelectionChangeCommitted

本文介绍了获取新的值或指数与DataGridView的组合框的SelectionChangeCommitted事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IM使用SelectionChangeCommitted当一个组合框选定的索引改为赶上事件,但我无法得到它的新的价值或索引。

 私人无效ruleList_EditingControlShowing(对象发件人,DataGridViewEditingControlShowingEventArgs E)
{
如果(e.Control是组合框)
{
组合框下拉框中= e.Control作为组合框;
comboBox.SelectionChangeCommitted + = ruleListColumnComboSelectionChanged;
}
}

私人无效ruleListColumnComboSelectionChanged(对象发件人,EventArgs五)
{
字符串值= ruleList.CurrentCell.Value.ToString(); //之前更改
}


解决方案

您可以用得到的新值:

 组合框下拉框中= sender.Control作为组合框; 
MessageBox.Show(comboBox.Text);


im using SelectionChangeCommitted to catch the event when a combobox selected index changed, but I can not get it's new value or index.

private void ruleList_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
    {
        if (e.Control is ComboBox)
        {
            ComboBox comboBox = e.Control as ComboBox;
            comboBox.SelectionChangeCommitted += ruleListColumnComboSelectionChanged;
        }
    }

    private void ruleListColumnComboSelectionChanged(object sender, EventArgs e)
    {
        string value = ruleList.CurrentCell.Value.ToString(); // just return the old value before the change
    }
解决方案

You can get the new Value using:

ComboBox comboBox = sender.Control as ComboBox;
MessageBox.Show(comboBox.Text);

这篇关于获取新的值或指数与DataGridView的组合框的SelectionChangeCommitted事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 03:00