Options

cdoverlaw

Well-known member
Joined
Oct 11, 2003
Messages
146
Hi
My program has an options form which needs to allow the user to chose whether they want the program to always be on top, i am using the code
Code:
Private Sub cmdOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOK.Click
        If chkTop.Checked = True Then
            Me.TopMost = True
        End If

        Me.Hide()

End Sub
but i want this to apply to my form called frmMain.vb which is already open, how can i do this, i tried
Code:
frmMain.TopMost = True
but i got an errror

Jonathan
 
You are going to have to send a reference to frmMain in to the Sub New() of your other, not-frmMain, form.
Sub New(TopForm As Form)
and declare a variable in the Form class that you can access from cmdOK_Click
Private MyTopForm As Form
Then, you can set MyTopForm.TopMost :).
 
*sigh*
Code:
Private ReferenceTofrmMain As Form
Public Sub New(PassfrmMainHere As Form)
ReferenceTofrmMain = PassfrmMainHere
And then you access the ReferenceTofrmMain as if it was frmMain.
 

Similar threads

Back
Top