c# - How to select(changing color) dynamically created button in continuous way without skip -


i have dynamically created buttons, eg 1,2,3,4,5,6,7,8; if select 2,3,4, can't select 6 , skip 4. or can say, if select 2,3,4,5,6 if want deselect 4 have deselect 5 , 6 first.

    private void getcontrols()     {         count++;         (int = 10; < 12; i++)         {             (int j = 0; j < 60; j += 15)             {                 button btn = new button();                 btn.text = + "-" + j;                 btn.id = + "." + j;                 btn.command += new commandeventhandler(this.btn_click);                // btn.click += btn_click;                 flag = true;                 btn.commandname = + "-" + j;                 if (count==1)                 {                     placeholder1.controls.add(btn);                      list<string> createdcontrols = session["controls"] != null ? session["controls"] list<string> : new list<string>();                     if (!createdcontrols.contains(btn.id)) createdcontrols.add(btn.id);                     session["controls"] = createdcontrols;                 }              }        }         }      private void btn_click(object sender, commandeventargs e)     {         count++;         //resetbutton();         button btn = sender button;         string id = (sender button).id;         string text = (sender button).text;         resetbutton(convert.todouble(id));         label1.text = " congrates! meeting time has been sheduled between " + id;       }  //}     private void resetbutton(double selectedbuttonid)     {         list<string> createdcontrols = session["controls"] != null ? session["controls"] list<string> : new list<string>();         timespan timespan = timespan.fromhours(selectedbuttonid);         string currentselectedtime = timespan.tostring("h\\:mm");         foreach (string buttonid in createdcontrols)         {             if (!string.isnullorempty(buttonid))             {                 int comparisonresult = timespan.compareto(timespan.fromhours(convert.todouble(buttonid)));                 button button = page.findcontrol(buttonid) button;                 if (button != null && comparisonresult >= 0 )                 {                      if (button.backcolor == color.yellow)                     {                         button.backcolor = system.drawing.color.ghostwhite;                     }                      else if (button.backcolor == color.ghostwhite)                     {                         button.backcolor = system.drawing.color.ghostwhite;                      }                     else                     {                          button.backcolor = system.drawing.color.yellow;                     } 


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -