How to get the control according to the control Id and operate on the control
This article mainly introduces "how to get the control according to the control Id and operate the control". In the daily operation, it is believed that many people have doubts about how to get the control according to the control Id and operate the control. The editor consulted all kinds of materials and sorted out a simple and useful operation method. I hope it will be helpful for you to answer the question of "how to get a control according to the control Id and operate on the control"! Next, please follow the editor to study!
When doing dynamic acquisition of a control, it is often necessary to get the control according to Id and operate on it, using the
The copy code is as follows:
/ / /
/ / get the control according to the control id
/ / /
/ / /
/ / /
Private Control GetControl (string name)
{
Object o = this.GetType () .GetField (name, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.IgnoreCase) .GetValue (this)
Return ((Control) o)
}
This method can quickly find the control.
At this point, the study on "how to get the control according to the control Id and operate on the control" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!