.net - Left align the toolbars by code -


is there way left align toolbars (without leaving "spaces") code? enter image description here

(say, when clicking button2) enter image description here

ps
situation

enter image description here
"left align" means :
enter image description here

update

based upon criteria changing quite dramatically, here code going. not perfect nor close being perfect!

public partial class form1 : form {     public form1()     {         initializecomponent();         _otherstrips = new list<otherstrips>();     }      private int _currentheight = 0;     private list<otherstrips> _otherstrips;      private void button1_click(object sender, eventargs e)     {         foreach (var c in panel1.controls)         {             if (c toolstrip)             {                 toolstrip ts = (toolstrip)c;                 _otherstrips.add(new otherstrips() { top = ts.top, width = ts.width, name = ts.name });                 movetoposition(ts);             }         }     }      private void movetoposition(toolstrip toolstrip)     {         bool isinline;         toolstrip.left = getwidth(toolstrip, out isinline);           if (isinline)             toolstrip.top = gettop(toolstrip);     }      private int getwidth(toolstrip ts, out bool isinline)     {         int result = 0;         isinline = false;         foreach (var item in _otherstrips)         {             if (item.name == ts.name)                 continue;              if (item.top == ts.top)             {                 isinline = true;                 break;             }         }          if (!isinline)             return result;          foreach (var item in _otherstrips)         {             if (item.width == ts.width)                 result += item.width;         }          return result + 22;//hack since width out 22pixels. not going spend time fixing     }      private int gettop(toolstrip ts)     {         foreach (var item in _otherstrips)         {             if (item.name == ts.name)                 continue;              if (item.top == ts.top)                 return item.top;         }          _currentheight += ts.height;         return _currentheight;     } }  struct otherstrips {     public int top { get; set; }     public int width { get; set; }     public string name { get; set; } } 

Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -