multirow一列单元格中,判断某个单元格为谋值时,进行操作
我在multirow中想要选中某一列,然后在这一列中,想要找到某个单元格,判断是否为某个值,如果是这个值就进行确认弹窗,如果不是这个值就进行错误弹窗。你好,如下的代码即可获取到(0,0)单元格的值
gcMultiRow.GetValue(0,0) 好的,我试一下,真的谢谢您 我想直接选中这一行,让他自己挨个判断这一行的所有值,这个能实现吗。大神 请参考下面的代码,看看是否是你想要的功能
gcMultiRow.SelectionChanged += (s, e) =>
{
var selectedRows = gcMultiRow.SelectedRows;
if (selectedRows.Count > 0)
{
var firstSelectedRowIndex = selectedRows.First().Index;
var contains = false;
for (var i = 0; i < gcMultiRow.Columns.Count; i++)
{
var value = gcMultiRow.GetValue(firstSelectedRowIndex, i);
if (value != null && (string)value == "aa")
{
contains = true;
}
}
if (contains)
{
MessageBox.Show("contains aa");
}
else
{
MessageBox.Show("not contains aa");
}
}
}; 大神,可以用vb语言发一下吗。 gcMultiRow.SelectionChanged += (s, e) =>
{
Dim selectedRows As var =gcMultiRow.SelectedRows
If selectedRows.Count > 0 Then
Dim firstSelectedRowIndex As var =selectedRows.First().Index
Dim contains As var =False
Dim i As var
Fori = 0 TogcMultiRow.Columns.Count- 1Stepi + 1
Dim value As var =gcMultiRow.GetValue(firstSelectedRowIndex,i)
If value <> Nothing And CType(value = "aa",String) Then
contains = True
End If
Next
If contains Then
MessageBox.Show("contains aa")
Else
MessageBox.Show("not contains aa")
End If
End If
} 十分感谢! 不客气
页:
[1]