0

我有一个名为 grdLOB 的 Janus GridEx 控件,它可以有多行。每行都有一个复选框和 3 个附加列。如果未选中某行(GL)上的复选框,我需要遍历网格并取消选中其他行中的复选框。

这是我的代码,但显然它不起作用......

Private Sub grdLOB_CellValueChanged(ByVal sender As Object, ByVal e as Janus.Windows.GridEX.ColumnActionEventArgs) Handles grdLOB.CellValueChanged

    If e.Column.Key = cSelector Then
        Dim grd As Janus.Windows.GridEX.GridEX = CType(sender, GridEX)
        Dim row As GridEXRow = grd.GetRow(grd.Row)

        Select Case row.Cells(1).Value.ToString().ToUpper()
            Case "GL"
                'If GL is checked, do nothing to the other rows.
                'If GL is unchecked, uncheck all the other rows.
                If CBool(row.Cells(0).Value) = False Then
                    For Each gr As GridEXRow In grdLOB.GetRows()
                        gr.BeginEdit()
                        gr.Cells(0).Value = False
                        gr.EndEdit()
                    Next
                End If
            Case Else
                'If a row other than GL is unchecked, do nothing to the other rows.
                'If a row other than GL is checked, then check the GL row.
                If CBool(row.Cells(0).Value) = True Then
                    For Each gr As GridEXRow In grdLOB.GetRows()
                        If gr.Cells(1).Value = "GL" Then
                            gr.BeginEdit()
                            gr.Cells(0).Value = True
                            gr.EndEdit()
                        End If
                    Next
                End If
        End Select
    End If

End Sub

如何在 GridEx 中动态选中\取消选中复选框?

4

1 回答 1

0

弄清楚了。这是更改后的有效 Select Case 代码:

Select Case row.Cells(1).Value.ToString().ToUpper()
            Case "GL"
                'If GL is checked, do nothing to the other rows.
                'If GL is unchecked, uncheck all the other rows.
                If CBool(row.Cells(0).Value) = False Then
                    For i As Integer = 0 To grdLOB.RowCount - 1
                        Dim gr As GridEXRow = grdLOB.GetRow(i)
                        gr.IsChecked = False
                    Next
                End If
            Case Else
                'If a row other than GL is unchecked, do nothing to the other rows.
                'If a row other than GL is checked, then check the GL row.
                If CBool(row.Cells(0).Value) = True Then
                    For i As Integer = 0 To grdLOB.RowCount - 1
                        Dim gr As GridEXRow = grdLOB.GetRow(i)
                        If gr.Cells(1).Value = "GL" Then
                            gr.IsChecked = True
                        End If
                    Next
                End If
        End Select
于 2019-08-21T15:05:37.320 回答