I am trying to use some C# code that expands on the GridView functionality in a VB.NET project. The code I’m using is from here.
In the C# code there is an event definition for GroupHeader:
/// <summary>
/// Event triggered after a row for group header be inserted
/// </summary>
public event GroupEvent GroupHeader;
This is expanded by example on the above web site:
protected void Page_Load(object sender, EventArgs e)
{
GridViewHelper helper = new GridViewHelper(this.GridView1);
helper.RegisterGroup("ShipRegion", true, true);
helper.RegisterGroup("ShipName", true, true);
helper.GroupHeader += new GroupEvent(helper_GroupHeader);
helper.ApplyGroupSort();
}
private void helper_GroupHeader(string groupName, object[] values, GridViewRow row)
{
if (groupName == "ShipRegion")
{
row.BackColor = Color.LightGray;
row.Cells[0].Text = " " + row.Cells[0].Text;
}
else if (groupName == "ShipName")
{
row.BackColor = Color.FromArgb(236, 236, 236);
row.Cells[0].Text = " " + row.Cells[0].Text;
}
}
My question is, how do I convert this code to VB.NET?
I have converted the event implementation like so:
Private Sub helper_GroupHeader(ByVal groupName As String, ByVal values As Object(), ByVal row As GridViewRow)
Try
If groupName = "ITEM#" Then
row.BackColor = Color.LightBlue
row.Cells(0).Text = " " & row.Cells(0).Text
End If
Catch ex As Exception
End Try
End Sub
How can I then call (raise?) this event with VB.NET?
You’re looking for
AddHandler:I assume that the event is implicitely raised from
GridViewHelper.