本文介绍了从grdview获得控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用行和列索引在Windows窗体应用程序中获取gridview单元格控件.控件意味着gridviw单元格中的combox

我可以使用(ComboBox)e.Control从那里的EditingControlShowing事件中获取它;

我的问题是如何使用行和列索引获取它.

How to get the gridview cell control in windows form application using row and column index. controls means combox in gridviw cell

I can get it from EditingControlShowing event in there using (ComboBox)e.Control;

My question is how to get it using row and column index

推荐答案

private void DGV_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
    {
    comboBOX = (ComboBox)e.Control;
    comboBOX .SelectedIndexChanged -=new EventHandler(comboBOX _SelectedIndexChanged);
    comboBOX .SelectedIndexChanged +=new EventHandler(comboBOX _SelectedIndexChanged);
    }
    private void comboBOX _SelectedIndexChanged(object sender, EventArgs e)
    {
    ComboBox combo = sender as ComboBox;
    string str=combo.SelectedIndex.ToString();
    }


这篇关于从grdview获得控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 13:49