Switching Documents with an Form Open

Switching Documents with an Form Open

SRSDS
Advisor Advisor
799 Views
6 Replies
Message 1 of 7

Switching Documents with an Form Open

SRSDS
Advisor
Advisor

I have a form open that relates to a specific document.

If I switch documents I would either like the form to either close or update contents to the current document.

 

How do I globally define a form to be able to handle it in the reactor? At the moment I only know how to locally define a form and close it.

 

    Private Sub btn_Click(sender As Object, e As EventArgs) Handles btn_Click
        Dim frm As Windows.Forms.Form = New frmMyFrm
        frm.Show()
    End Sub
0 Likes
Accepted solutions (1)
800 Views
6 Replies
Replies (6)
Message 2 of 7

norman.yuan
Mentor
Mentor
Accepted solution

I assume that you do know that if the form is shown as Modal Form, you cannot open another document, or switch to another document. So, the form has to be modeless form (floating form), or PaletteSet.

 

This article of mine written a few years ago might be of help:

 

http://drive-cad-with-code.blogspot.ca/2014/02/showing-and-closing-modeless-formdialog.html

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 7

ActivistInvestor
Mentor
Mentor

@SRSDS wrote:

I have a form open that relates to a specific document.

If I switch documents I would either like the form to either close or update contents to the current document.

 

How do I globally define a form to be able to handle it in the reactor? At the moment I only know how to locally define a form and close it.

 

    Private Sub btn_Click(sender As Object, e As EventArgs) Handles btn_Click
        Dim frm As Windows.Forms.Form = New frmMyFrm
        frm.Show()
    End Sub

The form has to be modeless, and you can use data binding to update its contents when the active document changes.

 

The problem and complications are pretty much the same for PaletteSets and modeless forms.  See this post for some more detail on how to go about using data binding to display data from the active document, and have it update when the active document changes.

0 Likes
Message 4 of 7

SRSDS
Advisor
Advisor

Showing my ineptitude here but how do I refer to the form in other modules?

 

    Implements IExtensionApplication
    Private Shared formSchedule As frmSchedule = Nothing

 

 

0 Likes
Message 5 of 7

ActivistInvestor
Mentor
Mentor

@SRSDS wrote:

Showing my ineptitude here but how do I refer to the form in other modules?

 

    Implements IExtensionApplication
    Private Shared formSchedule As frmSchedule = Nothing

 

 


Are you familiar with what 'Private' and 'Public' mean?

0 Likes
Message 6 of 7

SRSDS
Advisor
Advisor

 

Sorry. I must have hit undo before copying the code.

Changing it to Public doesn't change anything.

 

When trying to refer to the form in other modules it states that the form is not declared.

0 Likes
Message 7 of 7

SRSDS
Advisor
Advisor

I was declaring it within a class and not a module.

Sorry.  And thanks again for the help.

 

0 Likes