用程序對控件的taborder 排序

procedure FixTabOrder(const Parent: TWinControl) ;
   var
     ctl, L: Integer;
     List: TList;
   begin
     List := TList.Create;
     try
       for ctl := 0 to Parent.ControlCount - 1 do
       begin
         if Parent.Controls[ctl] is TWinControl then
         begin
           if List.Count = 0 then
        L := 0
           else
           begin
             with Parent.Controls[ctl] do
               for L := 0 to List.Count - 1 do
                 if (Top < TControl(List[L]).Top) or ((Top = TControl(List[L]).Top) and (Left < TControl(List[L]).Left)) then Break;
           end;
 
           List.Insert(L, Parent.Controls[ctl]) ;
           FixTabOrder(TWinControl(Parent.Controls[ctl])) ;
           end;
         end;
 
       for ctl := 0 to List.Count - 1 do
         TWinControl(List[ctl]).TabOrder := ctl;
     finally
       List.Free;
     end;
   end;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章