J
John
Hi,
This is my first experiment with C#, I'm trying to handle the resize
event. According to the documentation I should handle the Layout event
for this. My question is: how do I register this event? The following
code does not work because I never recieve the OnLoad event. What am I
doing wrong?
public class frmMain : System.Windows.Forms.Form
{
protected virtual void OnLoad(EventArgs e)
{
frmMain.ActiveForm.Layout += new
System.Windows.Forms.LayoutEventHandler(this.frmMain_Layout);
}
private void frmMain_Layout(object sender,
System.Windows.Forms.LayoutEventArgs e)
{
splMain.Left = pgTasks.Left + pgTasks.Width;
splMain.Height = this.Height;
}
}
Another question, while I'm here, the line:
frmMain.ActiveForm.Layout += new
System.Windows.Forms.LayoutEventHandler(this.frmMain_Layout);
does not make sense to me. I would think that the line should be:
this.ActiveForm.Layout += new
System.Windows.Forms.LayoutEventHandler(this.frmMain_Layout);
replacing 'frmMain' with 'this' but the 'this' object reference has a
very different set of intellisense attributes, of which ActiveForm is
not one of them.
Thanks
This is my first experiment with C#, I'm trying to handle the resize
event. According to the documentation I should handle the Layout event
for this. My question is: how do I register this event? The following
code does not work because I never recieve the OnLoad event. What am I
doing wrong?
public class frmMain : System.Windows.Forms.Form
{
protected virtual void OnLoad(EventArgs e)
{
frmMain.ActiveForm.Layout += new
System.Windows.Forms.LayoutEventHandler(this.frmMain_Layout);
}
private void frmMain_Layout(object sender,
System.Windows.Forms.LayoutEventArgs e)
{
splMain.Left = pgTasks.Left + pgTasks.Width;
splMain.Height = this.Height;
}
}
Another question, while I'm here, the line:
frmMain.ActiveForm.Layout += new
System.Windows.Forms.LayoutEventHandler(this.frmMain_Layout);
does not make sense to me. I would think that the line should be:
this.ActiveForm.Layout += new
System.Windows.Forms.LayoutEventHandler(this.frmMain_Layout);
replacing 'frmMain' with 'this' but the 'this' object reference has a
very different set of intellisense attributes, of which ActiveForm is
not one of them.
Thanks