// récupère un objet de type Label en fournissant son nom // nom = propriété Name private Label GetLabelByName(string name) { foreach (Control control in this.Controls) { if (control.Name == name) { return (Label)control; } } return null; }
Label myLabel = GetLabelByName("label1"); // par exemple ...