Solved

Transferring a variable to a form

Posted on 2010-11-15
2
224 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

730 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