怎样获取DataGridView中某行某列控件? winform开发,怎样获取DataGridView中某行某列控件?我想做的是,假如DataGridViewComboboxColumn有两个值,Some和All。当DataGridView中某行某列选择Some时,删除掉这行这列的绑定控件。这个控件是动态创建的,所以名称相同。我现在不知道该怎样获取到某行某列的控件? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 能详细点吗?DataGridView.Rows[r].Cells[1]没有findcontrol dataGridView1[1, dataGridView1.CurrentCell.RowIndex].Value).Trim() DataGridView.Rows[r].Cells[1]下面看看,应该是有地. int rowIndex=DataGridView.CurrentRowIndex;int cellIndex=DataGridView.CurrentCell.RowIndex;DataGridView.Rows[rowIndex].Cells[cellIndex] DataGridView.Rows[rowIndex].Cells[cellIndex]下面也没有控件啊 private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { try { if(dataGridView1.CurrentCell.ColumnIndex==1 && dataGridView1.CurrentCell.RowIndex!=-1) //控制行、列 { ComboBox combo = sender as ComboBox; //这里就是你要的控件 } } catch(Exception ex) { } }注意:如果该单元格不处于编辑模式下,或者单元格类型不适用于编辑控件,则此属性将返回空引用!也就是说,平常DataGridView.EditingControl 属性都是为null,只有在编辑单元格时,才能获取! 楼上的我没试过,下面这个我以前用过,是可以获取到单元格编辑时的控件的private void dgvSettleInfo_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { Control control = e.Control; } 我在DataGridView中单击绑定的按钮,这个按钮所在的行并没有被触发,而是另一行被触发。我怎样能获取这一行的值? 符号"|"的使用意思是什么? 如何在隐藏层内实现无刷新 急。。。。 如何实现点打印后立即进行打印,而不需要出现选择打印机的窗口 母版页和内容页的变量同名问题 如何打印自己做的图形控件? XML WEB SERVICE问题! dsoframer如何实现文档保存到远程服务器上 在图形处理中,Alpha Channel的作用是什么,请高手解析一下!!! webservice soap C#怎么实现从浏览器获取当前访问网页的URL 求助 BinaryFormatter.Deserialize 引发 System.OutOfMemoryException 异常
int cellIndex=DataGridView.CurrentCell.RowIndex;
DataGridView.Rows[rowIndex].Cells[cellIndex]
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
try
{
if(dataGridView1.CurrentCell.ColumnIndex==1 && dataGridView1.CurrentCell.RowIndex!=-1) //控制行、列
{
ComboBox combo = sender as ComboBox; //这里就是你要的控件
}
}
catch(Exception ex)
{ }
}注意:如果该单元格不处于编辑模式下,或者单元格类型不适用于编辑控件,则此属性将返回空引用!也就是说,平常DataGridView.EditingControl 属性都是为null,只有在编辑单元格时,才能获取!
{
Control control = e.Control; }