Delphi XE2 之 FireMonkey 入門(41) – 控制項基礎: TListBox

來源:互聯網
上載者:User
TScrollBox -> TCustomListBox -> TListBox; 其元素項是 TListBoxItem 類型.

TListBox 的功能在 TCustomListBox 裡就完成了.

值得注意的變化是:
1、複選框(相關屬性: ShowCheckboxes、TListBoxItem.IsChecked)
2、交替背景(通過繼承還可以調整交替的背景色)
3、TListBoxItem 可調整大小、容納其它對象.

{ TCustomListBox }public  constructor Create(...); override;          //  destructor Destroy; override;               //  procedure Assign(...); override;            //  procedure Clear; virtual;                   //清空  function DragChange(...): Boolean; dynamic; //調用 OnDragChange 事件  procedure SelectAll;                        //全選  procedure ClearSelection;                   //取消選擇  procedure SelectRange(...);                 //選擇指定範圍  function ItemByPoint(...): TListBoxItem;    //擷取指定位置的項  function ItemByIndex(...): TListBoxItem;    //擷取指定序號的項  procedure Exchange(...);                    //交換項  procedure AddObject(...); override;         //添加項  procedure RemoveObject(...); override;      //刪除項  procedure Sort(...); override;              //排序  property Count: Integer ...;                //項總數  property Selected: TListBoxItem ...;        //當前選擇的項  property Items: TStrings ...;               //元素文本的集合  property ListItems[Index: Integer]: TListBoxItem ...; //根據索引擷取項  property ItemIndex: Integer ...;                      //索引end;{ TListBox }published  property StyleLookup;              //  property AllowDrag;                //是否允許拖放  property CanFocus;                 //  property DisableFocusEffect;       //  property TabOrder;                 //  property AlternatingRowBackground; //是否使用交替背景  property Columns;                  //列數; 預設 1  property HideSelectionUnfocused;   //在失去焦點時是否隱藏選擇  property Items;                    //  property ItemIndex;                //  property ItemWidth;                //項寬  property ItemHeight;               //項高  property ListStyle;                //列表樣式; TListStyle = (lsVertical, lsHorizontal);  property MultiSelect;              //是否允許多選; 為 True 時, 配合 Ctrl 鍵多選  property Sorted;                   //  property ShowCheckboxes;           //是否顯示複選框; 預設 False  property BindingSource;            //繫結來源  property OnChange;                 //有變化時  property OnChangeCheck;            //調整複選框時  property OnCompare;                //排序比較時  property OnDragChange;             //拖放項時end;{ TListBoxItem }public  constructor Create(...); override; //  property Data: TObject ...;        //  property Index: Integer ...;       //published  property IsChecked: Boolean ...;   //複選值  property IsSelected: Boolean ...;  //  property AutoTranslate ...;        //  property Font;                     //  property StyleLookup;              //  property Text;                     //  property TextAlign ...;            //  property WordWrap;                 //end;
測試:
procedure TForm1.FormCreate(Sender: TObject);var  i: Integer;begin  ListBox1.Align := TAlignLayout.alLeft;  ListBox1.ShowCheckboxes := True;  ListBox1.AlternatingRowBackground := True;  for i := 0 to 9 do  begin    ListBox1.Items.Add('Itme' + IntToStr(i));    ListBox1.ListItems[i].IsChecked := Odd(i);  end;end;

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.