C# coding folks - pass string variable from Form to Form

Posted on 2013-06-11
Last Modified: 2013-06-17
Hello experts,

I have a Form.cs file, that contains a station_id variable that I want to pass to my next form:

        public Form1()
            System.Security.Principal.WindowsIdentity user =

                ITerminalServicesManager manager = new TerminalServicesManager();
                using (ITerminalServer server = manager.GetLocalServer())
                    foreach (ITerminalServicesSession session in server.GetSessions())
                        if (session.UserAccount != null && (user.Name.Split('\\')[1].ToLower() == session.UserName.ToLower()))
                            [b]string  station_id[/b] = Environment.MachineName + ":" + session.SessionId;

Open in new window

I also have a Form2.cs report with:

        public CrystalDecisions.Shared.IParameterField [b]Parameter_stationvariable[/b] {
            get {
                return this.DataDefinition.ParameterFields[1];

Open in new window

I want to build the code that will pass the station_id string to the Parameter_stationvariable in Form2cs above.  I am at a loss with C# - any ideas?

Question by:robthomas09
LVL 74

Accepted Solution

käµfm³d   👽 earned 400 total points
Comment Utility
LVL 29

Assisted Solution

anarki_jimbel earned 100 total points
Comment Utility

Author Closing Comment

Comment Utility

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: Ivo
Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 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

10 Experts available now in Live!

Get 1:1 Help Now