按钮点击事件的调用功能

时间:2015-07-29 11:03:22

标签: vb.net

如何在按钮点击事件中调用此vb.net函数?

Private Sub GridView_UDGReport_DataBound1(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.DataBound

    For rowIndex As Integer = GridView_UDGReport.Rows.Count - 2 To 0 Step -1
        Dim gviewRow As GridViewRow = GridView_UDGReport.Rows(rowIndex)
        Dim gviewPreviousRow As GridViewRow = GridView_UDGReport.Rows(rowIndex + 1)
        For cellCount As Integer = 0 To gviewRow.Cells.Count - 1
            If gviewRow.Cells(cellCount).Text = gviewPreviousRow.Cells(cellCount).Text Then
                If gviewPreviousRow.Cells(cellCount).RowSpan < 2 Then
                    gviewRow.Cells(cellCount).RowSpan = 2
                Else
                    gviewRow.Cells(cellCount).RowSpan = gviewPreviousRow.Cells(cellCount).RowSpan + 1
                End If
                gviewPreviousRow.Cells(cellCount).Visible = False
            End If
        Next
    Next
End Sub

2 个答案:

答案 0 :(得分:1)

由于您还没有使用这些参数,因此您只需使用Nothing作为参数调用该方法。

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    GridView_UDGReport_DataBound1(Nothing, Nothing)
End Sub

答案 1 :(得分:0)

追加第一行,以便子处理多个事件,如下所示:

Private Sub GridView_UDGReport_DataBound1(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.DataBound, Button1.Click

或者,如果除了调用此子之外,如果您需要Click事件运行其他代码,请执行以下操作:

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    'do something
    GridView_UDGReport_DataBound1(sender, e)
    'do something else
End Sub