请高手提供    <
            <<
            >
            >>   这些按钮的delphi源代码。。谢谢!

解决方案 »

  1.   


    unit Unit2;interfaceuses 
      Windows, Messages, SysUtils, Classes, Graphics, Forms, Dialogs, Controls, StdCtrls, 
      Buttons;type
      TDualListDlg = class(TForm)
        OKBtn: TButton;
        CancelBtn: TButton;
        HelpBtn: TButton;
        SrcList: TListBox;
        DstList: TListBox;
        SrcLabel: TLabel;
        DstLabel: TLabel;
        IncludeBtn: TSpeedButton;
        IncAllBtn: TSpeedButton;
        ExcludeBtn: TSpeedButton;
        ExAllBtn: TSpeedButton;
        procedure IncludeBtnClick(Sender: TObject);
        procedure ExcludeBtnClick(Sender: TObject);
        procedure IncAllBtnClick(Sender: TObject);
        procedure ExcAllBtnClick(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
        procedure MoveSelected(List: TCustomListBox; Items: TStrings);
        procedure SetItem(List: TListBox; Index: Integer);
        function GetFirstSelection(List: TCustomListBox): Integer;
        procedure SetButtons;
      end;var
      DualListDlg: TDualListDlg;implementation{$R *.dfm}procedure TDualListDlg.IncludeBtnClick(Sender: TObject);
    var
      Index: Integer;
    begin
      Index := GetFirstSelection(SrcList);
      MoveSelected(SrcList, DstList.Items);
      SetItem(SrcList, Index);
    end;procedure TDualListDlg.ExcludeBtnClick(Sender: TObject);
    var
      Index: Integer;
    begin
      Index := GetFirstSelection(DstList);
      MoveSelected(DstList, SrcList.Items);
      SetItem(DstList, Index);
    end;procedure TDualListDlg.IncAllBtnClick(Sender: TObject);
    var
      I: Integer;
    begin
      for I := 0 to SrcList.Items.Count - 1 do
        DstList.Items.AddObject(SrcList.Items[I],
          SrcList.Items.Objects[I]);
      SrcList.Items.Clear;
      SetItem(SrcList, 0);
    end;procedure TDualListDlg.ExcAllBtnClick(Sender: TObject);
    var
      I: Integer;
    begin
      for I := 0 to DstList.Items.Count - 1 do
        SrcList.Items.AddObject(DstList.Items[I], DstList.Items.Objects[I]);
      DstList.Items.Clear;
      SetItem(DstList, 0);
    end;procedure TDualListDlg.MoveSelected(List: TCustomListBox; Items: TStrings);
    var
      I: Integer;
    begin
      for I := List.Items.Count - 1 downto 0 do
        if List.Selected[I] then
        begin
          Items.AddObject(List.Items[I], List.Items.Objects[I]);
          List.Items.Delete(I);
        end;
    end;procedure TDualListDlg.SetButtons;
    var
      SrcEmpty, DstEmpty: Boolean;
    begin
      SrcEmpty := SrcList.Items.Count = 0;
      DstEmpty := DstList.Items.Count = 0;
      IncludeBtn.Enabled := not SrcEmpty;
      IncAllBtn.Enabled := not SrcEmpty;
      ExcludeBtn.Enabled := not DstEmpty;
      ExAllBtn.Enabled := not DstEmpty;
    end;function TDualListDlg.GetFirstSelection(List: TCustomListBox): Integer;
    begin
      for Result := 0 to List.Items.Count - 1 do
        if List.Selected[Result] then Exit;
      Result := LB_ERR;
    end;procedure TDualListDlg.SetItem(List: TListBox; Index: Integer);
    var
      MaxIndex: Integer;
    begin
      with List do
      begin
        SetFocus;
        MaxIndex := List.Items.Count - 1;
        if Index = LB_ERR then Index := 0
        else if Index > MaxIndex then Index := MaxIndex;
        Selected[Index] := True;
      end;
      SetButtons;
    end;end.
      

  2.   

    这题简单,Delphi自带的,上一帖了源代码,你也可以在Delphi中:New-->Other-->Forms-->Dual list box
      

  3.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        ListBox1: TListBox;
        ListBox2: TListBox;
        Button1: TButton;
        Button2: TButton;
        Button3: TButton;
        Button4: TButton;
        procedure Button2Click(Sender: TObject);
        procedure Button4Click(Sender: TObject);
        procedure Button1Click(Sender: TObject);
        procedure Button3Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button2Click(Sender: TObject);
    var i:integer;
    begin
      for i:=0 to self.ListBox1.Items.Count-1 do
       begin
        self.ListBox2.Items.Add(self.ListBox1.Items[i]);
       end;
         self.ListBox1.Items.Clear;end;procedure TForm1.Button4Click(Sender: TObject);
    var m:integer;
    begin
      for m:=0 to self.ListBox2.Items.Count-1 do
       begin
        self.ListBox1.Items.Add(self.ListBox2.Items[m]);
       end;
         self.ListBox2.Items.Clear;end;
    procedure TForm1.Button1Click(Sender: TObject);
    var
      I: Integer;
    begin
      for I := self.ListBox1.Items.Count - 1 downto 0 do
        if self.ListBox1.Selected[I] then
        begin
          self.ListBox2.Items.Add(self.ListBox1.Items[I]);
          self.ListBox1.Items.Delete(I);
        end;
    end;
    procedure TForm1.Button3Click(Sender: TObject);
    var
      n: Integer;
    begin
      for n:= self.ListBox2.Items.Count - 1 downto 0 do
        if self.ListBox2.Selected[n] then
        begin
          self.ListBox1.Items.Add(self.ListBox2.Items[n]);
          self.ListBox2.Items.Delete(n);
        end;
    end;end.