Delphi PageControl.TTabSheet与DriveComboBox.items同步

procedure TForm1.Button1Click(Sender: TObject);

Var

   X,I,Y:integer;

  cText:String;

  bNext:Boolean;

  T : TTabSheet;

begin



 For I:=0 to Self.DriveComboBox1.Items.Count-1 do

   begin

     cText:=DrivecomboBox1.Items.Strings[i];

     bNext:=True;

     for Y:=0 to Self.PageControl1.PageCount-1 do

        begin

           IF Self.PageControl1.Pages[i].Caption=cText then bNext:=False;

          end;

      IF bNext then

        begin

          with T do

            begin

               T:=TTabSheet.Create(Self.PageControl1);

               T.Caption:=cText;

                PageControl:=Self.PageControl1; 

               bNext:=False;

              end;

         end;

    end;



    repeat

      begin

     for Y:=0 to Self.PageControl1.PageCount-1 do

      begin

        cText:=Self.PageControl1.Pages[Y].Caption;

        bNext:=False;

        For I:=0 to Self.DriveComboBox1.Items.Count-1 do

          begin

             IF Self.DriveComboBox1.Items.Strings[i]=cText then

                begin

                   bNext:=True;

                end;

            end;

          IF Not bNext then

             begin

               Self.PageControl1.Pages[Y].Destroy;

               Break;

               end;

        end; end;

      Until PageControl1.PageCount=Self.DriveComboBox1.Items.Count;

不是什么高深的技术,我只是一个菜鸟,只能分享一些比较菜的语法。

你可能感兴趣的:(combobox)