I have a User Control that contains a grid and some buttons.
I declare GridAfterRowActivate
event for User Control:
public event EventHandler GridAfterRowActivate;
private void Grid_AfterRowActivate(object sender, EventArgs e)
{
if (GridAfterRowActivate != null)
GridAfterRowActivate(sender, e);
}
I added this User Control to my form. When I fill grid in form constructor, GridAfterRowActivate
event does not raise. But when I fill grid in Form_Load
, this event works correctly.
I'd imagine that it's because you filled the control in the constructor, but the control's Init event isn't called until after the page's
PreInit
. You should fill the control at the earliest on the page'sInit
event.