VB.NET What is Sender used for?

前端 未结 3 620
不知归路
不知归路 2020-12-18 00:41

I\'m confused as to the purpose of the sender parameter in Winform controls, for example:

Private Sub Form1_Load(sender As System.Object, e As S         


        
3条回答
  •  悲&欢浪女
    2020-12-18 01:07

    e refers to the event arguments for the used event, they usually come in the form of properties/functions/methods that get to be available on it.

    In this example the label text property will contain the BorderColor set for the footer style of our GridView when its FooterRow, determined from the row sent as a property on the event arguments parameter, binds the data with the GridView DataSource.

    Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
            If e.Row.RowType = DataControlRowType.Footer Then
                lblFooterColor.Text = e.Row.Style("BorderColor")
            End If
    End Sub
    

提交回复
热议问题