解决方案 »
- 用Delphi XE2创建Apple iOS程序
- 烦心的Application.OnMessage:= 在主程序中部分无效
- 128个2进制串转16进制
- 这个循环怎么做啊。。谢谢!!
- 散个小分!!!呵呵!
- 用DBGRID分页显示数据,“第一页”“上一页”“下一页”“末页”这四个按钮的编程要怎样实现?
- 在Win2000下,如何通过程序设置“打印首选项”,坐着等。
- Delphi新手提问,怎样编写Tstringgrid中某个单元格的ONENTER,ONEXIT事件?
- 我的按钮不见了!好奇怪!
- 如何做一个播放列表,请各位提示
- delphi读取access表格的内容-错误标准表达式数据类型不匹配
- 获得光标绝对坐标?
unit Unit1;interfaceuses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;type
TForm1 = class(TForm)
grp1: TGroupBox;
chk1: TCheckBox;
lbl1: TLabel;
edt1: TEdit;
cbb1: TComboBox;
grp2: TGroupBox;
lbl2: TLabel;
chk2: TCheckBox;
edt2: TEdit;
cbb2: TComboBox;
grp3: TGroupBox;
lbl3: TLabel;
chk3: TCheckBox;
edt3: TEdit;
cbb3: TComboBox;
btn1: TButton;
procedure btn1Click(Sender: TObject);
procedure ChangeState(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}//==============================================================================
// 获取点击值
//==============================================================================procedure TForm1.btn1Click(Sender: TObject);
var
I, J, K: Integer;
sOutPut: string;
begin
for I := 0 to ControlCount - 1 do
begin
if (Controls[I] is TGroupBox) then
with TGroupBox(Controls[I]) do
begin
for J := 0 to ControlCount - 1 do
begin
if Controls[J] is TCheckBox then
begin
if TCheckBox(Controls[j]).Checked then
begin
sOutPut := sOutPut + '处罚' + TCheckBox(Controls[j]).Caption + ':';
with TCheckBox(Controls[j]).Parent do
begin
for K := 0 to ControlCount - 1 do
begin
if Controls[K] is TEdit then
sOutPut := sOutPut + TEdit(Controls[K]).Text + '元、';
end;
end;
end;
end;
end;
end;
end;
if Length(sOutPut) > 0 then
Delete(sOutPut, Length(sOutPut), 1);
ShowMessage(sOutPut); //修改此行调用导出Word的自定义过程或者函数
end;//==============================================================================
// 点击CheckBox改变对应GroupBox范围内控件(不包含CheckBox)的激活状态
//==============================================================================procedure TForm1.ChangeState(Sender: TObject);
var
I, J: Integer;
begin
for I := 0 to ControlCount - 1 do
begin
if (Controls[I] is TGroupBox) and (Controls[I].Name = TCheckBox(Sender).Parent.Name) then
with TGroupBox(Controls[I]) do
begin
for J := 0 to ControlCount - 1 do
begin
if Controls[J] is TLabel then
TLabel(Controls[J]).Enabled := TCheckBox(Sender).Checked;
if Controls[J] is TEdit then
TEdit(Controls[J]).Enabled := TCheckBox(Sender).Checked;
if Controls[J] is TCombobox then
TCombobox(Controls[J]).Enabled := TCheckBox(Sender).Checked;
end;
end;
end;
end;end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
private
{ Private declarations }
procedure CheckBoxClick(Sender: TObject);
public
{ Public declarations }
end;var
Form1: TForm1;implementation
{$R *.dfm}
const str:array[0..10] of string=('项目经理','队长','机电队长','生产队长','技术主管',
'技术员','跟班队长','电工','风筒工','打眼工','其他人员');
type TchBox = Record
CheckBox: TCheckBox;
iLabel: TLabel;
Edit: TEdit;
ComboBox: TComboBox;
end;var
chb:array[0..10]of TchBox;
ls:TStringlist;
GroupBox4: TGroupBox;
Memo: TMemo;procedure TForm1.FormCreate(Sender: TObject);
var i,j,x:integer;
begin
ls:=TStringlist.Create;
GroupBox4:=TGroupBox.Create(self);
with GroupBox4 do begin
Parent:=self;
Left:=40;
Top:=24;
Height:=290;
Width:=730;
end;
Memo:=TMemo.Create(self);
with Memo do begin
Parent:=self;
Left:=40;
Top:=320;
Height:=120;
Width:=730;
end;
for i:=0 to 1 do begin
for j:=0 to 5 do begin
x:=i*6+j;
if x>10 then exit;
chb[x].CheckBox:=TCheckBox.Create(GroupBox4);
with chb[x].CheckBox do begin
Parent:=GroupBox4;
Caption:=str[x];
Tag:=x;
Left:=16+j*120;
Top:=24+i*136;
OnClick:=CheckBoxClick;
end;
chb[x].iLabel:=TLabel.Create(GroupBox4);
with chb[x].iLabel do begin
Parent:=GroupBox4;
Caption:='Label_'+inttostr(x+1);
Left:=16+j*120;
Top:=48+i*136;
Enabled:=false;
end;
chb[x].Edit:=TEdit.Create(GroupBox4);
with chb[x].Edit do begin
Parent:=GroupBox4;
Left:=16+j*120;
Top:=64+i*136;
Width:=98;
Enabled:=false;
end;
chb[x].ComboBox:=TComboBox.Create(GroupBox4);
with chb[x].ComboBox do begin
Parent:=GroupBox4;
Left:=16+j*120;
Top:=96+i*136;
Width:=98;
Enabled:=false;
end;
end;
end;
end;procedure TForm1.CheckBoxClick(Sender: TObject);
var s:string;
i,index:integer;
b:boolean;
begin
with TCheckBox(Sender) do begin
b:=Checked;
s:=Caption;
index:=Tag;
end;
with chb[index] do begin
ComboBox.Enabled:=b;
Edit.Enabled:=b;
iLabel.Enabled:=b;
end;
if TCheckBox(Sender).Checked then
ls.Append(s)
else
ls.Delete(ls.IndexOf(s));
s:='';
for i:=0 to ls.Count-1 do
s:=s+ls.Strings[i]+'、';
s:=copy(s,1,length(s)-2)+'。';
if s='。' then
memo.Text:=''
else
memo.Text:=s;
end;procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if ls<>nil then
FreeAndNil(ls);
if Memo<>nil then
FreeAndNil(Memo);
if GroupBox4<>nil then
FreeAndNil(GroupBox4);
end;end.