我的界面上有2个ComboBox控件,一个ToolButton按钮,一个RadioGroup1单选框。这个过程我是这么设计的:
只有当ComboBox我都输入内容并且RadioGroup1我选择了后,我才希望ToolButton确定,否则ToolButton按钮是灰色的,就是不能按下去。
这个功能我不想在ToolButton按钮下实现,想在ComboBox和RadioGroup1下实现,请问在哪里触发事件,该怎么编,谢谢!
只有当ComboBox我都输入内容并且RadioGroup1我选择了后,我才希望ToolButton确定,否则ToolButton按钮是灰色的,就是不能按下去。
这个功能我不想在ToolButton按钮下实现,想在ComboBox和RadioGroup1下实现,请问在哪里触发事件,该怎么编,谢谢!
解决方案 »
- 60分求Delphi主窗体调用 Dll下的子Frame或form
- delphi做OCX浏览WEB服务器上TIFF文件
- 打印问题
- 不知道哪里有 dbisam 现成的例子?
- 新手做项目遇到几个小问题,望各位大侠帮忙看看解决一下!比较紧!!
- 请问StringGrid的多表头的问题
- 怎样检测Query是否为空?
- 在Delphi中怎样调用GOOGLE的API搜索歌曲并且使程序得到搜索歌曲的URL
- taxi(游少爷)进来看看:
- 请教,在delphi中,如何当我的程序运行时,令桌面上的其他窗体最小化?
- AcroPDFLib组件去哪儿找啊?
- 如何把一个clientdataset中的几个字段的数据赋值给另一个Clientdataset啊?
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ComCtrls, ToolWin;type
TForm1 = class(TForm)
ComboBox1: TComboBox;
ComboBox2: TComboBox;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
RadioGroup1: TRadioGroup;
Label1: TLabel;
procedure ComboBox1Change(Sender: TObject);
procedure ComboBox2Change(Sender: TObject);
procedure RadioGroup1Click(Sender: TObject);
private
{ Private declarations }
function CheckCanUseButton(cmb1, cmb2: TComboBox; rg: TRadioGroup): Boolean;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}function TForm1.CheckCanUseButton(cmb1, cmb2: TComboBox; rg: TRadioGroup): Boolean;
begin
Result := (cmb1.Text <> '') and (cmb2.Text <> '') and (rg.ItemIndex <> -1);
end;procedure TForm1.ComboBox1Change(Sender: TObject);
begin
ToolButton1.Enabled := CheckCanUseButton(ComboBox1, ComboBox2, RadioGroup1);
end;procedure TForm1.ComboBox2Change(Sender: TObject);
begin
ToolButton1.Enabled := CheckCanUseButton(ComboBox1, ComboBox2, RadioGroup1);
end;procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
ToolButton1.Enabled := CheckCanUseButton(ComboBox1, ComboBox2, RadioGroup1);
end;end.
在RadioGroup的OnClick事件里检测ComboBox.text和RadioGroup.itemindex
两个事件里写的判断都是一样:if (ComboBox.text <> '') and (RadioGroup.itemindex <> -1) then
ToolButton.Enable := True
else
ToolButton.Enable := False;