Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-06-11
3
Medium Priority
?
211 Views
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()
        {
            InitializeComponent();
            System.Security.Principal.WindowsIdentity user =
                        System.Security.Principal.WindowsIdentity.GetCurrent();

            MessageBox.Show(user.Name);
            try
            {
                ITerminalServicesManager manager = new TerminalServicesManager();
                using (ITerminalServer server = manager.GetLocalServer())
                {
                    server.Open();
                    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:


        [Browsable(false)]
        [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
        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?

Thanks!
0
Comment
Question by:robthomas09
3 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 1600 total points
ID: 39238952
0
 
LVL 30

Assisted Solution

by:anarki_jimbel
anarki_jimbel earned 400 total points
ID: 39239912
0
 

Author Closing Comment

by:robthomas09
ID: 39253596
Thanks!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

824 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