Tuesday, 2 August 2011

Dot net factory windows forms class


Perform operation on Msgbox using windows form classes :

Set MyMsgBox = DotNetFactory.CreateInstance("System.Windows.Forms.MessageBox","System.Windows.Forms")
MyMsgBox.Show "A","B"




Perform operations on forms


Set Form = DotNetFactory.CreateInstance("System.Windows.Forms.Form", "System.Windows.Forms")
Form.ShowDialog




Performing operation on forms and adding button to form :

Set MyForm = DotNetFactory.CreateInstance("System.Windows.Forms.Form", "System.Windows.Forms")
Set MyButton = DotNetFactory.CreateInstance("System.Windows.Forms.Button", "System.Windows.Forms")
MyForm.Controls.Add MyButton
MyButton.Text = "Close"
MyForm.ShowDialog



Performing operation on forms and adding button to it at the required position :
Now we can change the position using (DotNetFactory.CreateInstance("System.Drawing.Point","System.Drawing",x,y)) class

Set Form = DotNetFactory.CreateInstance("System.Windows.Forms.Form", "System.Windows.Forms")
Set Button = DotNetFactory.CreateInstance("System.Windows.Forms.Button", "System.Windows.Forms")
Set Pos = DotNetFactory.CreateInstance("System.Drawing.Point","System.Drawing",x,y)
With Pos
.X = 100
.Y = 100
End With
With Button
.Text = "Close"
.Location = Pos
End With
With Form
.Controls.Add Button
.CancelButton = Button
.Text = "My Custom User Form"
.ShowDialog
End With
Set Form = Nothing
Set Button = Nothing
Set Pos = Nothing






No comments:

Post a Comment