Saturday, 6 August 2011

Add text box control to the forms : (Dot net factory)



Set Form = DotNetFactory.CreateInstance("System.Windows.Forms.Form","System.Windows.Forms")
Set Text = DotNetFactory.CreateInstance("System.Windows.Forms.TextBox", "System.Windows.Forms")
Form.Controls.Add Text
Form.ShowDialog






Now we can change the position using (DotNetFactory.CreateInstance("System.Drawing.Point","System.Drawing",x,y)) class

Set Pos = DotNetFactory.CreateInstance("System.Drawing.Point","System.Drawing",x,y)
Pos.X = 10
Pos.Y = 20
Text.Location = Pos




So the full code for the text box a required position will be :

Set Form = DotNetFactory.CreateInstance("System.Windows.Forms.Form", "System.Windows.Forms")
Set Text = DotNetFactory.CreateInstance("System.Windows.Forms.TextBox", "System.Windows.Forms")
Set Pos = DotNetFactory.CreateInstance("System.Drawing.Point","System.Drawing",x,y)
Pos.X = 100
Pos.Y = 100
Text.Location = Pos
Text.Width = 150
Form.Controls.Add Text
Form.ShowDialog



No comments:

Post a Comment