TListBox 有两个兄弟 TComboListBox、TComboEditListBox;
TComboBox、TComboEdit 虽不是不是从它们继承, 但分别包含了它们, 所以使用起来都有点像 TListBox.

TComboBox 更像 TListBox, 比 TComboEdit 多出了 Selected 等成员;
TComboEdit 是从 TCustomEdit 继承, 和 TEdit 是兄弟, 比 TComboBox 多出了 Text 等成员.

它们的公共常用属性:
DropDownCount //下拉列表行的数
ItemHeight    //
ItemIndex     //
Items         //
Count         //


测试:

procedure TForm1.FormCreate(Sender: TObject);
var
  i: Integer;
begin
  { ComboBox1 }
  for i := 0 to 9 do
    ComboBox1.Items.Add(Format('Item_%d', [i]));
  with ComboBox1 do
  begin
    ItemIndex := 0;
    DropDownCount := 5;
    ListBox.UseSmallScrollBars := True;
    TListBox(ListBox).AlternatingRowBackground := True; //这个兄弟转换用得有点悬, 只是为了让 AlternatingRowBackground 属性暴露出来
  end;

  { ComboEdit1 }
  ComboEdit1.Items.Assign(ComboBox1.Items);
  with ComboEdit1 do
  begin
    ItemIndex := 0;
    DropDownCount := 5;
    ListBox.UseSmallScrollBars := True;
    TListBox(ListBox).AlternatingRowBackground := True;
  end;
//  ComboEdit1.Text := 'Text';
end;

posted on 2011-10-08 23:35  万一  阅读(5467)  评论(0编辑  收藏  举报