How To Make New Form?
-
Hi All I Create A form Named ChildForm. In Main form I write This Codes
Dim ChFrm As New ChildForm
ChFrm.ShowBut I need to access the all form ( random) from Main Form. But I Can't Access This Forms. Please Help Me. Tanks. Mogtabam
-
Hi All I Create A form Named ChildForm. In Main form I write This Codes
Dim ChFrm As New ChildForm
ChFrm.ShowBut I need to access the all form ( random) from Main Form. But I Can't Access This Forms. Please Help Me. Tanks. Mogtabam
Do you want the collection of forms like form1, form2 form3 then or you want particular form with refernce to the parent.
Develop2Program & Program2Develop
-
create an MDI Form as your main form. make all other form's
IsMDIChild
property to true. now you can access all the form from your main form.Live life to the fullest
Hi And Tanks For Your Replys. But My Problem Not Solved Yet. Because I Want To Access then form and its Components (for example A textbox). I Need To Change It From Main Form. if i have 1 form This is Ok. But I have several form With One Name; For Example Can You Write For Me A Code That Change The TextBox In First MdiChild & Put Another Text In Another MdiChilform? Example: ChForm:My Child Form Have a textbox MainForm: My Main Form have a button Named But In Main form:
sub But_click()
dim Cf as new ChForm
Cf.show
end subAfter Tow Or More Click On But I Need To Access TextBox In the ChildForm. Can You Help Me? Tanks. Mogtabam
-
Hi And Tanks For Your Replys. But My Problem Not Solved Yet. Because I Want To Access then form and its Components (for example A textbox). I Need To Change It From Main Form. if i have 1 form This is Ok. But I have several form With One Name; For Example Can You Write For Me A Code That Change The TextBox In First MdiChild & Put Another Text In Another MdiChilform? Example: ChForm:My Child Form Have a textbox MainForm: My Main Form have a button Named But In Main form:
sub But_click()
dim Cf as new ChForm
Cf.show
end subAfter Tow Or More Click On But I Need To Access TextBox In the ChildForm. Can You Help Me? Tanks. Mogtabam
Declare the form outside the method (in the global area of the main form, and then create the new form in the button handler. The then the new form object will be available globally within the main form:
Public Class MainForm As Form
Public Cf as ChForm
sub But_click()
Cf = new ChForm
Cf.showend sub
End Class
However, keep in mind that what you want to do (directly access a control on one form from another) is really bad practice. You should be building properties on the other forms and using them to access the data provided in controls on the form as shown bellow:
Public Class MainForm As Form
Public Cf as ChForm
Private mNameData As Stringsub But_click()
Cf = new ChForm
Cf.showmNameData - Cf.NameData()
end sub
End Class
Public Class ChForm As Form
Public Property NameData() As String
Get
Return txtName.TextEnd Get Set (value as String) txtName.Text = value End Set
End Property
End Class
This keeps things much cleaner and more modular.
-
Hi All I Create A form Named ChildForm. In Main form I write This Codes
Dim ChFrm As New ChildForm
ChFrm.ShowBut I need to access the all form ( random) from Main Form. But I Can't Access This Forms. Please Help Me. Tanks. Mogtabam
first of all u want to make an MDI parent and child form and u want to access it thru parent form... first of all make form 1 as parent b making its property as is MDI container as true.. nw put a pic box (optional) and put a button on it.. add a form make its property as is MDI child as true.. i hope u knw this much nw in button code.. Dim NewMDIChild As New Form2 'Set the Parent Form of the Child window. NewMDIChild.MdiParent = Me 'Display the new form. NewMDIChild.Show() .. after this i am not getting yr query.. if u have any further query lemme know..