[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 255
  • Last Modified:

Pass variable from 1 section of code to another

Hi
Can anyone tell me how I can get the value of strOrderNumber to display in lblDisplayOrderNumber.Text
lblDisplayOrderNumber is in a different panel to strOrderNumber.

Regards
Caz

private void btnProceed_Click(object sender, System.EventArgs e)
{
// code
strOrderNumber = "Order number" + " " + sqlComRetrieveOrderNumber.Parameters["@RETURN_VALUE"].Value.ToString();
}

private void btnCheckDetails_Click(object sender, System.EventArgs e)
{
lblDisplayOrderNumber.Text = strOrderNumber;
}
0
BeginningWebDesign
Asked:
BeginningWebDesign
1 Solution
 
vinhnlCommented:
what you mean?-->lblDisplayOrderNumber is in a different panel to strOrderNumb
0
 
djhoenCommented:
When you say that lblDisplayOrderNumber is in a different panel to strOrderNumber, does that mean that they are in a different form or the same form?

If they are on the same form you would just need to make strOrderNumber a class variable.

If they are on a different form, you could create a property for your strOrderNumber like so:

public StrOrderNumber
{
  get
  {
    return strOrderNumber;
  }
  set
  {
    strOrderNumber = value;
  }
}

you would need to add a reference to the form that has the strOrderNumber in the constructor - like so:

form2(form1 f1)
{
  //class logic
 
  f1.StrOrderNumber = value;
}
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now