三颗纽扣

世界上最宽广的是海洋,比海洋更宽广的是天空,比天空更宽广的是人的胸怀

导航

自动设置 TabStop 值

好长时间没上来了,发个小技巧,根据控件的位置自动调整 TabStop 值,免得一个一个的设置麻烦。

 1         public void AutoTabStop()
 2         {
 3             AutoTabStop(this);
 4         }
 5 
 6         private static void AutoTabStop(Control container)
 7         {
 8             foreach (Control ctrl in container.Controls)
 9             {
10                 if (ctrl.TabStop)
11                 {
12                     var y = ctrl.Top;
13                     var x = ctrl.Left;
14 
15                     ctrl.TabIndex = y * 10 + x/100;
16                 }
17                 
18                 AutoTabStop(ctrl);
19             }
20         }

21  

 

 

posted on 2009-11-09 15:31  三颗纽扣  阅读(213)  评论(0)    收藏  举报