急!!!请问怎么实现通过一个按钮按下来控制另一个按钮弹起,谢谢!

xrhone 2009-09-17 09:56:59
两个差不多的问题,请帮忙,谢谢!
1、首先按下一个按钮A凹下去,按下B时,A按钮弹起,但是B按钮不凹下去

2、当两个按钮不在同一个panel中时,怎么实现按下A按钮时,A按钮凹进去,按下B按钮时,A按钮弹起,B按钮凹进去!



...全文
556 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
yhcustc 2011-12-16
  • 打赏
  • 举报
回复
a.Down := not b.Down
Harryfin 2009-09-18
  • 打赏
  • 举报
回复
Rz的按钮也有GroupIndex属性,不一定用SpeedButton
imho888 2009-09-18
  • 打赏
  • 举报
回复

procedure TForm1.RzButton1Click(Sender: TObject);
begin
RzButton1.GroupIndex:= 1;
RzButton1.Down:= true;
end;

procedure TForm1.RzButton2Click(Sender: TObject);
begin
RzButton1.GroupIndex:= 0;
RzButton1.Down:= false;
end;
xrhone 2009-09-17
  • 打赏
  • 举报
回复
直接写成下面这种是不行的,我试过。
按钮a事件里 a.down:=true;
按钮b事件里 a.down:=false; b.down:=false;
haitao 2009-09-17
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 xrhone 的回复:]
我的程序不适合用bevel

其实最主要的是要解决第一个问题:“首先按下一个按钮A凹下去,按下B时,A按钮弹起,但是B按钮不凹下去”

就是要用B按钮来通过代码控制A按钮弹起。

请帮忙看看,谢谢!
[/Quote]
不要设groupid,
按钮a事件里 a.down:=true;
按钮b事件里 a.down:=false; b.down:=false;
xrhone 2009-09-17
  • 打赏
  • 举报
回复
我的程序不适合用bevel

其实最主要的是要解决第一个问题:“首先按下一个按钮A凹下去,按下B时,A按钮弹起,但是B按钮不凹下去”

就是要用B按钮来通过代码控制A按钮弹起。

请帮忙看看,谢谢!
caixiaobai08 2009-09-17
  • 打赏
  • 举报
回复
o
haitao 2009-09-17
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 xrhone 的回复:]
我是用的Tspeedbutton,但是group只能是在同一panel中有效,在不同的panel中无效
[/Quote]

哦,这倒没注意,d7的帮助没说。。。。。。。。
Allows speed buttons to work together as a group.

Delphi syntax:

property GroupIndex: Integer;

C++ syntax:

__property int GroupIndex = {read=FGroupIndex, write=SetGroupIndex, default=0};

Description

Set GroupIndex to determine how the button behaves when clicked.

When GroupIndex is 0, the button behaves independently of all other buttons on the form. When the user clicks such a speed button, the button appears pressed (in its clicked state) and then returns to its normal up state when the user releases the mouse button.

When GroupIndex is greater than 0, the button remains selected (in its down state) when clicked by the user. When the user clicks a selected button, it returns to the up state, unless Caption is false. Setting the GroupIndex property of a single speed button to a value greater than 0 causes the button to behave as a two-state button when Caption is true.

Speed buttons with the same GroupIndex property value (other than 0), work together as a group. When the user clicks one of these buttons, it remains selected until the user clicks another speed button belonging to the same group. Speed buttons used in this way can present mutually exclusive choices to the user.




把panel改为bevel呢?
xrhone 2009-09-17
  • 打赏
  • 举报
回复
我是用的Tspeedbutton,但是group只能是在同一panel中有效,在不同的panel中无效
haitao 2009-09-17
  • 打赏
  • 举报
回复
哦,Tspeedbutton才有groupid
haitao 2009-09-17
  • 打赏
  • 举报
回复
如果按钮有group属性,可以自动有这样的功能的:同一group的按钮,同时只会有一个是陷下去的

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧