我正在尝试使用一些 C# 代码来扩展 VB.NET 项目中的 GridView 功能。我使用的代码来自这里。
在 C# 代码中有一个 GroupHeader 的事件定义:
/// <summary>
/// Event triggered after a row for group header be inserted
/// </summary>
public event GroupEvent GroupHeader;
这通过上述网站上的示例进行了扩展:
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;
}
}
我的问题是,如何将此代码转换为 VB.NET?
我已经像这样转换了事件实现:
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
然后我怎样才能用 VB.NET 调用(引发?)这个事件?