Solved

Transferring a variable to a form

Posted on 2010-11-15
2
219 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

18 Experts available now in Live!

Get 1:1 Help Now