K
Kimmo Laine
Hello,
(how) can i do the following (in C#)?
// . . .
class MyForm : Form {
// . . .
protected Button myButton = null;
protected TextBox myTB = null;
protected void AddControl( ref Control ctrl, string strType, Size s,
Point pt, string txt ) {
ctrl = new < ?!?! >;
ctrl.Location = pt;
ctrl.Size = s;
ctrl.Text = txt;
Controls.Add( ctrl );
}
protected override void OnLoad( EventArgs e ) {
AddControl( myButton, "Button", new Size( ...), new Point( ... ),
"Dummy 1" );
AddControl( myTB, "TextBox", new Size( ...), new Point( ... ),
"Dummy 1" );
base.OnLoad( e );
}
}
It would be even better if the second parameter ( in AddControl ) could be
the actual type:
AddControl( myButton, Button, new Size( ...), new Point( ... ),
"Dummy 1" );
AddControl( myTB, TextBox, new Size( ...), new Point( ... ), "Dummy
1" );
Thx!
- Kimmo Laine
(how) can i do the following (in C#)?
// . . .
class MyForm : Form {
// . . .
protected Button myButton = null;
protected TextBox myTB = null;
protected void AddControl( ref Control ctrl, string strType, Size s,
Point pt, string txt ) {
ctrl = new < ?!?! >;
ctrl.Location = pt;
ctrl.Size = s;
ctrl.Text = txt;
Controls.Add( ctrl );
}
protected override void OnLoad( EventArgs e ) {
AddControl( myButton, "Button", new Size( ...), new Point( ... ),
"Dummy 1" );
AddControl( myTB, "TextBox", new Size( ...), new Point( ... ),
"Dummy 1" );
base.OnLoad( e );
}
}
It would be even better if the second parameter ( in AddControl ) could be
the actual type:
AddControl( myButton, Button, new Size( ...), new Point( ... ),
"Dummy 1" );
AddControl( myTB, TextBox, new Size( ...), new Point( ... ), "Dummy
1" );
Thx!
- Kimmo Laine