Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hey there... I know this is gonna sound like a pretty easy thing to solve, as I'm learning a lot about vb.net as I go along - I'm learning that Micro has reinvented the wheel and made our lives that little bit more difficult. Well not really but having to relearn all the syntax and logic flow is a bit annoying.

 

The problem I am having it with a SDI App I a writing, I have a main form, with a settings form that is loaded with the click of a button. I am trying to pass the variables from the settings form to the Main form. Some of the settings are in listboxes and some are in comboboxes.

 

in VB6 you used to be able to do the following

form1.listbox1.list = form2.listbox.list

but now you can't - Damn Java look-a-like VB.net!!! :mad:

 

:confused:

Apparently there is a way to do it with modal forms and/or form inheritance - But as I'm still learning there is a lot I don't know. Would someone please assist me with this regard? Even the smallest amount of code/help would be greatly appreciative.

 

Thanx in advance.

P.L.U.R - Peace, Love, Unity, Respect :P
  • *Experts*
Posted

Are you showing that form modally? If yes when using the ShowDialog method pass in your main form as an owner of the dialog and when working in your second form you will be able to access the main form using the Owner property.

If not, what you could do is edit your settings form's constructor to accept an instance of the main form and assign it to a local variable in your settings form and access the main form from that variable.

Posted

ummmmmmmmm

 

I am using a module to "open" and close" my forms accordingly...

Module mStart
   Public MainFrm As frmMain
   Public SetupDayFrm As frmSetupDay

   Public Sub main()

       MainFrm = New frmMain

       Application.Run(MainFrm)

   End Sub

End Module

 

I'm not sure how to display forms modally or otherwise as yet... And how can you edit the constructors of a form to do what you have sugested?

 

Many thanx

P.L.U.R - Peace, Love, Unity, Respect :P
Posted
'This goes in what ever event calls the frmSettings
Dim FS As New frmSettings(Me) 
       FS.ShowDialog()' form modally opened

'=================================


'In the frmSettings code, add this to the top of the class
Dim FormMain As frmMain


'Also add this to the frmSettings
Public Sub New(ByVal PassedFormName As frmMain) 'Add this also inside the brackets

        MyBase.New()

       FormMain = PassedFormName 'heres what you need to add
       
       InitializeComponent()

End Sub

'now you can access and control things back on the main form like FormMain.TextBox1.Text = txtPhoneNumber.text

'Hope This helps
'Mark

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...