全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1237
推到 Plurk!
推到 Facebook!

组合控件combobox+Button

 
sos_admin
版主


發表:121
回覆:697
積分:768
註冊:2003-07-23

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-09-18 10:35:39 IP:61.155.xxx.xxx 未訂閱
效果图 使用: procedure TForm1.FormCreate(Sender: TObject); begin BCB1.combobox.Items.Add('sos_admin'); BCB1.combobox.Items.Add('sos_admin2'); BCB1.combobox.ItemIndex :=0; BCB1.button.Caption :='...'; BCB1.Caption :=''; BCB2.combobox.Items.Add('sos_admin'); BCB2.combobox.Items.Add('sos_admin2'); BCB2.combobox.ItemIndex :=0; BCB2.button.Caption :='...'; BCB2.Caption :=''; end; procedure TForm1.BCB1buttonclick(Sender: TObject); begin showmessage('您好,bcb1:我是button'); end; procedure TForm1.BCB2buttonclick(Sender: TObject); begin showmessage('您好,bcb2:我是button'); end; 控件源码[bcb.pas] unit BCB; interface uses Windows, Messages, SysUtils, Classes, Controls, ExtCtrls, StdCtrls; type TBCB = class(TPanel) private Fcombobox:Tcombobox; Fbutton:Tbutton; FOnbuttonclick: TNotifyEvent; procedure buttonclick(sender:TObject);//作为按钮的事件 { Private declarations } protected { Protected declarations } public constructor Create(AOwner: TComponent); override; destructor Destroy; override; { Public declarations } published property button:Tbutton read Fbutton write Fbutton; property combobox:Tcombobox read Fcombobox write Fcombobox; property Onbuttonclick: TNotifyEvent read FOnbuttonclick write FOnbuttonclick; { Published declarations } end; procedure Register; implementation procedure Register; begin RegisterComponents('BCB', [TBCB]); end; constructor TBCB.Create(AOwner: TComponent); begin inherited; Fcombobox := Tcombobox.Create (Self); Fcombobox.Parent:=self; Fcombobox.Visible :=true; Fcombobox.Left :=0; Fcombobox.Top :=0; Fbutton:=Tbutton.Create(self); Fbutton.Parent :=self; Fbutton.Visible :=true; Fbutton.Left :=Fcombobox.Width+Fcombobox.Left; Fbutton.Top:= Fcombobox.Top ; Fbutton.Height:=20 ; Fbutton.Width :=20; Fbutton.OnClick :=buttonclick; end; procedure tbcb.buttonclick(sender:TObject); begin if Assigned(FOnbuttonclick) then FOnbuttonclick(sender); end; destructor TBCB.Destroy; begin if Fbutton<>nil then Fbutton.Free ; if Fcombobox<>nil then Fcombobox.Free ; inherited; end; end.
系統時間:2024-05-19 8:44:44
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!