How do I change/override the following lines of code from the designer? -
11-16-2007
, 04:33 PM
How do I change/override the following lines of code from the designer?
Thanks,
Schneider
Designer code below:
public class MyForm : System.Windows.Forms.Form
{
private System.ComponentModel.IContainer components;
private System.Windows.Forms.MonthCalendar m_Calendar;
private System.Windows.Forms.StatusBar statusBar1;
private System.Windows.Forms.Panel panel1;
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.statusBar1 = new System.Windows.Forms.StatusBar();
this.panel1 = new System.Windows.Forms.Panel();
//
// statusBar1 initialize
//
//
// panel1 initialize
//
this.Controls.Add(this.panel1);
this.Controls.Add(this.statusBar1);
}
#endregion
//----------------------------------------------------------
Desired code:
public class MyForm : System.Windows.Forms.Form
{
private m_MyFactory CustFactory = new CustFactory(); //how can I add this?
private System.ComponentModel.IContainer components; //same
private IStatusBar statusBar1; //override the type
private IPanel panel1; //override the type
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();//same
this.statusBar1 = m_MyFactory.CreateStatusBar(); //use factory method
call
this.panel1 = m_MyFactory.CreatePanel(); //use factory method call
//
// statusBar1 initialize
//
//
// panel1 initialize
//
this.Controls.Add((Control)this.panel1); //cast type
this.Controls.Add((Control)this.statusBar1);//cast type
}
#endregion |