delphi 组件问题 请高手帮我解决答一下 下面是我的代码,为这个程序会tpanel组会乱跳,不是按顺序排列
vari:Integer;Temp,Count:Integer;Txt:string;beginCurN:=StrToInt(RightStr(TPanel(Sender...
var
i:Integer;
Temp,Count:Integer;
Txt:string;
begin
CurN:=StrToInt(RightStr(TPanel(Sender).Name,1));
for i:=0 to Panel1.ControlCount-1 do
begin
if Panel1.Controls[i].ClassName='TPanel' then
begin
Temp:=StrToInt(RightStr(TPanel(Panel1.Controls[i]).Name,1));
if Temp>CurN then
TPanel(Panel1.Controls[i]).Align:=alBottom;
end;
end;
Count:=Panel1.ControlCount-1;
while Count>=0 do
begin
if Panel1.Controls[Count].ClassName='TPanel' then
begin
Temp:=StrToInt(RightStr(TPanel(Panel1.Controls[Count]).Name,1));
if Temp<=CurN then
TPanel(Panel1.Controls[Count]).Align:=alTop;
end;
Dec(Count);
end;
Lw.Clear;
for i:=0 to MainMenu1.Items[CurN-1].Count-1 do
begin
Txt:=MainMenu1.Items[CurN-1].Items[i].Caption ;
if Txt<>'' then
begin
Lw.Items.Add.Caption:=' '+Txt+' ';
end;
end;
end;
点击一panel组件,那个P6,P5,P4会顺序会倒到来,可不可让它按顺序排列
例如我组件面板是P1--到P6,点击了p3,下面的p3下的所有panel组件会按顺序排列
P4到P6这样排列 展开
i:Integer;
Temp,Count:Integer;
Txt:string;
begin
CurN:=StrToInt(RightStr(TPanel(Sender).Name,1));
for i:=0 to Panel1.ControlCount-1 do
begin
if Panel1.Controls[i].ClassName='TPanel' then
begin
Temp:=StrToInt(RightStr(TPanel(Panel1.Controls[i]).Name,1));
if Temp>CurN then
TPanel(Panel1.Controls[i]).Align:=alBottom;
end;
end;
Count:=Panel1.ControlCount-1;
while Count>=0 do
begin
if Panel1.Controls[Count].ClassName='TPanel' then
begin
Temp:=StrToInt(RightStr(TPanel(Panel1.Controls[Count]).Name,1));
if Temp<=CurN then
TPanel(Panel1.Controls[Count]).Align:=alTop;
end;
Dec(Count);
end;
Lw.Clear;
for i:=0 to MainMenu1.Items[CurN-1].Count-1 do
begin
Txt:=MainMenu1.Items[CurN-1].Items[i].Caption ;
if Txt<>'' then
begin
Lw.Items.Add.Caption:=' '+Txt+' ';
end;
end;
end;
点击一panel组件,那个P6,P5,P4会顺序会倒到来,可不可让它按顺序排列
例如我组件面板是P1--到P6,点击了p3,下面的p3下的所有panel组件会按顺序排列
P4到P6这样排列 展开
1个回答
展开全部
//是不是要这样的效果
var
i,position :Integer;
p :TPanel;
begin
position := StrToInt(RightStr(TPanel(Sender).Name,1));
for i := 1 to position do
begin
p := TPanel(Sender).Parent.FindChildControl('P' + IntToStr(i)) as TPanel;
p.Top := (i - 1) * p.Height;
p.Align := alTop;
end;
for i := 6 downto position + 1 do
begin
p := TPanel(Sender).Parent.FindChildControl('P' + IntToStr(i)) as TPanel;
p.Align := alBottom;
end;
end;
var
i,position :Integer;
p :TPanel;
begin
position := StrToInt(RightStr(TPanel(Sender).Name,1));
for i := 1 to position do
begin
p := TPanel(Sender).Parent.FindChildControl('P' + IntToStr(i)) as TPanel;
p.Top := (i - 1) * p.Height;
p.Align := alTop;
end;
for i := 6 downto position + 1 do
begin
p := TPanel(Sender).Parent.FindChildControl('P' + IntToStr(i)) as TPanel;
p.Align := alBottom;
end;
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询