table.open; table.first; for i:=0 to table.recordcount-1 do begin combobox1.items.add(table.fieldbyname('编号').asstring+table.fieldbyname('科目').asstring); table.next; end;
DELPHI的帮助中就有这样的例子 COPY下来给你,体会一下AddObject的用法 ---------------------------------------- This example requires a TPageControl already on the form. Also, you must add pages to the TPageControl by right clicking and selecting New Page. The example code will allow the user to select the ActivePage property through selection of a ComboBox item. During the form create, the Combo Box control is loaded with the names of each of the tabs, as well as the instance pointers to the corresponding tab. When the user selects the Combo Box item, the associated TTabSheet object contained in the Combo Box Objects array is used to set the ActivePage property.procedure TForm1.FormCreate(Sender: TObject);var i: Integer; begin for i := 0 to PageControl1.PageCount - 1 do ComboBox1.Items.AddObject(PageControl1.Pages[i].Name, PageControl1.Pages[i]); ComboBox1.ItemIndex := 0; end;procedure TForm1.ComboBox1Change(Sender: TObject); begin if (Sender is TComboBox) then with (Sender as TComboBox) do PageControl1.ActivePage := TTabSheet(Items.Objects[ItemIndex]);end;
table.first;
for i:=0 to table.recordcount-1 do
begin
combobox1.items.add(table.fieldbyname('编号').asstring+table.fieldbyname('科目').asstring);
table.next;
end;
COPY下来给你,体会一下AddObject的用法
----------------------------------------
This example requires a TPageControl already on the form. Also, you must add pages to the TPageControl by right clicking and selecting New Page.
The example code will allow the user to select the ActivePage property through selection of a ComboBox item. During the form create, the Combo Box control is loaded with the names of each of the tabs, as well as the instance pointers to the corresponding tab. When the user selects the Combo Box item, the associated TTabSheet object contained in the Combo Box Objects array is used to set the ActivePage property.procedure TForm1.FormCreate(Sender: TObject);var
i: Integer;
begin
for i := 0 to PageControl1.PageCount - 1 do
ComboBox1.Items.AddObject(PageControl1.Pages[i].Name,
PageControl1.Pages[i]);
ComboBox1.ItemIndex := 0;
end;procedure TForm1.ComboBox1Change(Sender: TObject);
begin
if (Sender is TComboBox) then
with (Sender as TComboBox) do
PageControl1.ActivePage := TTabSheet(Items.Objects[ItemIndex]);end;