0

I have a user control which assembles a string based on two text fields (first name and last name) and I'd like to have another label use this to say something like "Your name is FIRSTNAME LASTNAME".

Although I can see the public string the user control outputs, I can't find an event which specifies when the user control has new inputs.

It'd be great if I could do something like...

    private void userControl_Update()
    {
        lblYourName.Text = String.Format("Your name is {0}", userControl.name);
    }

But I have no idea how to do this.

I use VB2012 with visual c# and forms.

Thanks for any help.

Coat
  • 697
  • 7
  • 18

1 Answers1

1

It looks like you are using WinForms.

In that case, I believe the event you are looking for is the TextChanged event:

// Set using the visual Form Designer, generally
lblName.TextChanged += lblName_TextChanged;

// Later, the event handler
private void lblName_TextChanged(object sender, EventArgs e)
{
    lblYourName.Text = String.Format("Your name is {0}", lblName.Text);
}
Matt Dillard
  • 14,479
  • 7
  • 49
  • 61
  • My mistake. In the original question I implied that I wanted to grab the information off a label when really it's a custom user control with a custom field that I want. I've updated the question now. – Coat Sep 17 '13 at 00:39