主题:关于窗体的问题
sxfgf
[专家分:0] 发布于 2006-12-23 17:46:00
我想做一个,把主窗口分为左右两部分,左边窗体有5个按钮,分别控制右边窗体的显示与隐藏,比如:
按下左边窗体的按钮1,右边显示界面1;
按下左边窗体的按钮2,右边显示界面2;
.........
按下左边窗体的按钮5,右边显示界面5;
请问如何实现?
回复列表 (共8个回复)
沙发
冰封星云 [专家分:2260] 发布于 2006-12-23 21:15:00
我也想知道
板凳
中华韧峰 [专家分:600] 发布于 2006-12-23 23:27:00
用TNoteBook控件,在控件表WIN3.1下。
3 楼
极品泡饭 [专家分:90] 发布于 2006-12-25 08:21:00
你可以在窗体中放两个GroupBox控件,分别左右放置,再把相应的按钮分别放入两个GroupBox中,最后,你的事件只要触发这两个GroupBox显示或是隐藏即可
4 楼
league [专家分:0] 发布于 2006-12-25 13:27:00
你可以把右边要显示的界面分别建成一个单独的窗体。
然后再分别写用于显示窗体的函数。
不过窗体显示时要设置他的父窗体为先前窗体上的一具容器。
这样窗体显示时就成为先前那窗体的右边的一部分了。
我现在用的就是这样的方法。不知符不符合你的要求。
5 楼
sxfgf [专家分:0] 发布于 2006-12-25 15:53:00
谢谢大家的帮忙!
能说的具体一些吗?或者有实例也可以
6 楼
中华韧峰 [专家分:600] 发布于 2006-12-25 18:03:00
用TNoteBook控件,可以生成多页。点击某个按钮,显示其某一页就行了。
你可以试验一下,遇到问题再讨论。
7 楼
league [专家分:0] 发布于 2006-12-26 17:43:00
假设窗体是用Panel分为左右两部分。要在from1窗体的右边显示form2窗体。
procedure Tform1.CreateNewfrm;
var
frm: Tform2;
begin
try
FreeAndNil(frmpub);
frm:= Tform2.Create(nil);
frmpub:= frm;
frm.Align:= alClient;
frm.Parent:= Panel; 在这里Pnael为form1窗体的右边部分。
frm.DBGridTrainStuff.Align:= alClient;
frm.Update;
frm.BorderStyle:= bsNone;
frm.Show;
Finally
end;
end;
上面的函数写在form1窗体上,然后再调用这个函数来显示form2窗体。
要在{ Public declarations }下面定义一个frmpub: TWinControl;变量。
8 楼
dodolon [专家分:400] 发布于 2007-01-01 05:16:00
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Panel1: TPanel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
CurrentFrame: TFrame;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2, Unit3;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if CurrentFrame<>nil then
CurrentFrame.Free;
CurrentFrame:=TFrame1.Create(Self);
CurrentFrame.Parent:=Panel1;
CurrentFrame.Align:=alClient;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if CurrentFrame<>nil then
CurrentFrame.Free;
CurrentFrame:=TFrame2.Create(Self);
CurrentFrame.Parent:=Panel1;
CurrentFrame.Align:=alClient;
end;
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TFrame1 = class(TFrame)
private
{ Private declarations }
public
{ Public declarations }
end;
implementation
{$R *.dfm}
end.
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TFrame2 = class(TFrame)
private
{ Private declarations }
public
{ Public declarations }
end;
implementation
{$R *.dfm}
end.
我来回复