Grouping and Summary RRS feed

  • Question

  • User502904657 posted

    First post here!

    Sorry if I am breaking ediquite.

    I have been using the techniques shown here http://www.agrinei.com/gridviewhelper/gridviewhelper_en.htm

    Its been working well for me.  My site use VB rather than C#, but it hasn't been an issue until I tried to do some dressing up of the GroupHeader and GroupSummary. 

    The site above has the following sample:

    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);
    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;

    I am having trouble duplicating the following line from the above code into VB.  Any help is appreciated.

        helper.GroupHeader += new GroupEvent(helper_GroupHeader);



    Friday, December 3, 2010 12:10 PM

All replies

  • User-800449548 posted

    The same line with out the semicolon should work fine..

    helper.GroupHeader += New GroupEvent(helper_GroupHeader)

    Please mark as Answered if it helps.

    Friday, December 3, 2010 12:37 PM
  • User502904657 posted

    I am trying to make it work in VB.

    I get the error that it is an event and cannot be called directly.

    Friday, December 3, 2010 12:40 PM
  • User502904657 posted

    I was being dense about vb event handling... I got it figured out!  ;)


    In case anyone else stumbles across thread...

    For Event Handlers:

    In C#

    helper.GroupHeader += New GroupEvent(helper_GroupHeader)

    Is similar to the following in VB:

    AddHandler helper.GroupHeader, AddressOf helper_GroupHeader

    Monday, December 6, 2010 12:36 PM