Select,ActivePage,property,delphi

Omar 10/12/2016 0

This example requires a TPageControl already be on the form. Also, you must add pages to the TPageControl by right- clicking and selecting New Page. The example code allows you to select the ActivePage property through the selection of a ComboBox item. While the form is created, 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 you select the Combo Box item, the associated TTabSheet object contained in the Combo Box Objects array is used to set the ActivePage property. Select the Lines property of the TRichEdit to enter a string. Select the string before justifying.

Delphi
procedure TForm1.FormCreate(Sender: TObject);
var
  i: Integer;
const
  colorarray : Array[0..4] of TColor = (
    clYellow, clGreen, clBlue, clLime, clFuchsia);
begin
  for i := 0 to PageControl1.PageCount - 1 do
    begin
    PageControl1.Pages[i].Brush.Color := colorarray[i];
    ComboBox1.Items.AddObject(PageControl1.Pages[i].Name,
      PageControl1.Pages[i]);
    end;
  ComboBox1.ItemIndex := 0;
  PageControl1.ActivePage := TTabSheet(ComboBox1.Items.Objects[ComboBox1.ItemIndex]);
end;
 
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
  if (Sender is TComboBox) then
    with (Sender as TComboBox) do
      PageControl1.ActivePage := TTabSheet(Items.Objects[ItemIndex]);
end; 

Report Bug

Please Login to Report Bug

Reported Bugs

Comments

Please Login to Comment

Comments