c# - Access a button using its string name and change its back color -


i need access buttons using string names , change backcolor property.

i tried using this.control[string key] , this.controls.find(string, bool), none of these work.

 oledbconnection.open();  oledbcommand command = new oledbcommand("select * customer flightno = '" + variables.depflightno + "'", oledbconnection);   oledbdatareader reader = command.executereader();  while (reader.read())  {      string seat = reader[3].tostring();      this.controls[seat].backcolor = color.red;  }  reader.close(); 

oledbconnection.open(); oledbcommand command = new oledbcommand("select * customer flightno = '" + variables.depflightno + "'", oledbconnection);  oledbdatareader reader = command.executereader(); while (reader.read())     {         string seat = reader[3].tostring();         foreach (button s in this.controls)  //if controls in different place //like panel or groupbox change "this.controls" "groupbox.controls"         {            if (s.name == seat)            {               s.backcolor = color.yellow;            }         }      }     reader.close(); 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -