Opening a with a variable

Posted on 2011-09-14
Last Modified: 2012-05-12
Hi All

I'm trying to make my project bigger, the next step is to be able to click on a link an open a  form within the program. Eg. customer detail with ID 23547.

How would i go about this? I already have the sub process to open the section within the program but i need the bit to be able to pass a variable in to the program.


Question by:Matb396
  • 2
LVL 13

Expert Comment

by:Philip Pinnell
Comment Utility
You can create a contructor for the second form that accepts a parameter

  public partial class Form2 : Form
    private string strPassedText = "No parm";
    public Form2()
    public Form2(string strParm)
      strPassedText = strParm;

    private void Form2_Load(object sender, EventArgs e)
      this.label1.Text = strPassedText;

Then call it as follows

    private void button1_Click(object sender, EventArgs e)
      Form2 myform2 = new Form2("Hello World");



Author Comment

Comment Utility
Im on about a link from an email or something... so one of the empolyees can email the manager say "look at x y z " & Link... so when the link is clicked on the program auto loads up the a part within the program.

I need to know how to pass that variable in to a program?

Accepted Solution

Ironhoofs earned 500 total points
Comment Utility
If you are refering to command line parameters (i.e.: yourprogram.exe myparm) you can find a short tutorial here:


Author Comment

Comment Utility
ok that works how do you do something like spotify does, and have a much nice looking link like so


rather then :

O:\Delelopment\Freatures\CommandLineFeature\CommandLineFeature\bin\Release\CommandLineFeature.exe /CusID233454

So for example



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

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

744 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

13 Experts available now in Live!

Get 1:1 Help Now