简体   繁体   中英

How to put back-end code for a label in Visual Studio

I am beginner to the C# and Visual Studio. I just wanted to ask how to put back-end code for a label.Just like when we press a double click on a button. It's back-end code just appears in .cs file, just like below

private void UIButton97_TouchUpInside(UIButton sender)
{
}

So can we do the same thing with a label.

Any help is appreciated.

check event that available for label, and you can add some behavior in that event. for example i will use label in my current project :

  1. Add Event Text Changed in the label
  this.aboutLabel.TextChanged += new System.EventHandler(this.aboutLabel_TextChanged); 
  1. Define method that handle event like below
  private void aboutLabel_TextChanged(object sender, EventArgs e) { //do some bahaviour in here } 

The event above will be execute when text in label changed.

For simple way just right click --> properties in label element , click Events (In visual studio usually represent as thunderbolt image), double click empty field in beside event that you want to fire, see image below :

事件

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM