4 Replies - 14650 Views - Last Post: 11 September 2008 - 03:44 PM Rate Topic: -----

#1 wagau999  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 4
  • Joined: 11-September 08

Dynamic Form and controls Generation

Post icon  Posted 11 September 2008 - 01:14 PM

I would like to Create a new form and controls over it Dynamically. i ve used the below code for it. With this code i am only able to Create a New form Dynamically but not able to create the Button Control.

If FormName = "MIS" Then
If obj_CommonForm Is Nothing Then
obj_CommonForm = New Form
End If
obj_CommonForm.Show()
Dim btn_Create As New Button
btn_Create.Location = New System.Drawing.Point(30, 200)
btn_Create.Size = New System.Drawing.Size(60, 15)
btn_Create.Text = "MIS"
Me.Controls.Add(btn_Create)
End if

Is This A Good Question/Topic? 1

Replies To: Dynamic Form and controls Generation

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9390
  • View blog
  • Posts: 35,264
  • Joined: 12-June 08

Re: Dynamic Form and controls Generation

Posted 11 September 2008 - 01:29 PM

What is the button supposed to be attached to? I do not see it being attached to the obj_commonform.
Was This Post Helpful? 0
  • +
  • -

#3 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2268
  • View blog
  • Posts: 9,482
  • Joined: 29-May 08

Re: Dynamic Form and controls Generation

Posted 11 September 2008 - 02:16 PM

View Postwagau999, on 11 Sep, 2008 - 09:14 PM, said:

I would like to Create a new form and controls over it Dynamically. i ve used the below code for it. With this code i am only able to Create a New form Dynamically but not able to create the Button Control.
If FormName = "MIS" Then
			If obj_CommonForm Is Nothing Then
				obj_CommonForm = New Form
			End If
			obj_CommonForm.Show()
			Dim btn_Create As New Button
			btn_Create.Location = New System.Drawing.Point(30, 200)
			btn_Create.Size = New System.Drawing.Size(60, 15)
			btn_Create.Text = "MIS"
			Me.Controls.Add(btn_Create)
End if


Currently it is adding the control to the form where ever this code it.
Me. Is a self-reference to the form the code is in. (VB.net doesn't let you refer to it by name.)
Change to this
If FormName = "MIS" Then
			If obj_CommonForm Is Nothing Then
				obj_CommonForm = New Form
			End If
			obj_CommonForm.Show()
			Dim btn_Create As New Button
			btn_Create.Location = New System.Drawing.Point(30, 200)
			btn_Create.Size = New System.Drawing.Size(60, 15)
			btn_Create.Text = "MIS"
			obj_CommonForm.Controls.Add(btn_Create)
End if



PS :code:
Was This Post Helpful? 0
  • +
  • -

#4 wagau999  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 4
  • Joined: 11-September 08

Re: Dynamic Form and controls Generation

Posted 11 September 2008 - 03:39 PM

View Postmodi123_1, on 11 Sep, 2008 - 01:29 PM, said:

What is the button supposed to be attached to? I do not see it being attached to the obj_commonform.


Yes, that's true. I got Ur point. Can U tell me how can i bind it to the form.
Was This Post Helpful? 0
  • +
  • -

#5 wagau999  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 4
  • Joined: 11-September 08

Re: Dynamic Form and controls Generation

Posted 11 September 2008 - 03:44 PM

View PostAdamSpeight2008, on 11 Sep, 2008 - 02:16 PM, said:

View Postwagau999, on 11 Sep, 2008 - 09:14 PM, said:

I would like to Create a new form and controls over it Dynamically. i ve used the below code for it. With this code i am only able to Create a New form Dynamically but not able to create the Button Control.
If FormName = "MIS" Then
			If obj_CommonForm Is Nothing Then
				obj_CommonForm = New Form
			End If
			obj_CommonForm.Show()
			Dim btn_Create As New Button
			btn_Create.Location = New System.Drawing.Point(30, 200)
			btn_Create.Size = New System.Drawing.Size(60, 15)
			btn_Create.Text = "MIS"
			Me.Controls.Add(btn_Create)
End if


Currently it is adding the control to the form where ever this code it.
Me. Is a self-reference to the form the code is in. (VB.net doesn't let you refer to it by name.)
Change to this
If FormName = "MIS" Then
			If obj_CommonForm Is Nothing Then
				obj_CommonForm = New Form
			End If
			obj_CommonForm.Show()
			Dim btn_Create As New Button
			btn_Create.Location = New System.Drawing.Point(30, 200)
			btn_Create.Size = New System.Drawing.Size(60, 15)
			btn_Create.Text = "MIS"
			obj_CommonForm.Controls.Add(btn_Create)
End if



PS :code:


That's great! Thanks for the solution. It works for me.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1