Solved

Transferring a variable to a form

Posted on 2010-11-15
2
220 Views
Last Modified: 2012-06-27
I have a variable that is declared at execution. I need to get that variable into my form so I can access it. The variable I need is commandData. I cannot declare it public because the value is set at execution. Is there a way to pass a variable to a form? the only thing I can find is from one form to another. Here is the code:

 Public Function Execute(ByVal commandData As Autodesk.Revit.UI.ExternalCommandData, ByRef message As String, ByVal elements As Autodesk.Revit.DB.ElementSet) As Autodesk.Revit.UI.Result Implements Autodesk.Revit.UI.IExternalCommand.Execute
        Dim fm1 As New ContentBrowser()
        Dim components = New Container()
        Dim resources As New ResourceManager(GetType(ContentBrowser))
        Dim tabControl1 As New TabControl()
        Dim tabPage1 As New TabPage()
        Dim myImages As New ImageList(components)
        ' Construct the ImageList.
        Dim ImageList1 = New ImageList
        fm1.Show()
    End Function
0
Comment
Question by:mgsell
2 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 34141269
Sure you can...but your form needs a place to store it!

So you could either:
(1) Override the constructor so the value is received when you create a new instance of the form.
(2) Add a public member (or a private with a public property wrapper).

In either case, you need to add a variable of type Autodesk.Revit.UI.ExternalCommandData to the form:

    Public Class ContentBrowser

        Public CommandData As Autodesk.Revit.UI.ExternalCommandData

    End Class

Simple example of #2:

    Dim fm1 As New ContentBrowser()
    fm1.CommandData = commandData
    ...
0
 

Author Comment

by:mgsell
ID: 34146010
That worked perfectly!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
A short film showing how OnPage and Connectwise integration works.
A simple description of email encryption using a secure portal service. This is one of the choices offered by The Email Laundry for email encryption. The other choices are pdf encryption which creates an encrypted pdf of your email and any attachmen…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now