我的意思是现在有10个按钮visible均为false,caption均为空,根据qxb中的数据来定义这些按钮的visible属性和caption,qxb中的数据如下
role an caption form
总经理 Button1 接单查询 jdcx
总经理 Button2 出口发货查询 fhcx
总经理 Button3 内销发货统计 nxtjcx
总经理 Button4 客户数据分析 khsjfx
以上各字段均为string类型
procedure TForm1.Button2Click(Sender: TObject);
var
btn: TButton;
begin
qya.close;
qya.sql.clear;
qya.sql.add('select * from qxb where role=''总经理''');
qya.open;
while not qya.Eof do
begin
btn:=qya.fieldbyname('an').asstring;
btn.Visible := True;
qya.Next;
end;
end;
以上代码编译时提示‘incompatible:'TButton' and 'String'’;
请问该符合写代码?
role an caption form
总经理 Button1 接单查询 jdcx
总经理 Button2 出口发货查询 fhcx
总经理 Button3 内销发货统计 nxtjcx
总经理 Button4 客户数据分析 khsjfx
以上各字段均为string类型
procedure TForm1.Button2Click(Sender: TObject);
var
btn: TButton;
begin
qya.close;
qya.sql.clear;
qya.sql.add('select * from qxb where role=''总经理''');
qya.open;
while not qya.Eof do
begin
btn:=qya.fieldbyname('an').asstring;
btn.Visible := True;
qya.Next;
end;
end;
以上代码编译时提示‘incompatible:'TButton' and 'String'’;
请问该符合写代码?
解决方案 »
- Delphi打印程序有哪些方法可以实现?
- 有关rztabs的错误提示,请大家帮忙看看啥意思
- IdTCPServer的OnExecute事件中创建窗体的问题
- 有这样的组件吗,两维的,一个是象TStringlist一样,是字符串,另一组是Integer,当然两组Tstring也行
- 快速报表打印问题,大侠救命!!!!!!!!!!!
- 关于调出本机IP地址的程序
- 关于ActiveForm的问题?
- treeview的问题,请各位帮给以解决!
- 如何在quickreport中实现这样的报表?
- FreeNotification此方法的含义是什么
- FASTREPORT中ADOQUERY的问题
- 三层,客户端调用服务器方法,服务器怎么提供方法
procedure TForm1.Button4Click(Sender: TObject);
var
btnName :string;
i :integer;
begin
btnName := 'Button1';
for i := 0 to ComponentCount-1 do
if Components[i] is TButton then
begin
if TButton(Components[i]).Name = btnName then
begin
TButton(Components[i]).Caption := '接單查詢';
TButton(Components[i]).Visible := True;
end;
end;
end;
i: Integer;
btnArr: array [1..10] of TButton;
begin
for i := 0 to ControlCount - 1 do
begin
if Controls[i] is TButton then
btnArr[i+1] := TButton(Controls[i]);
end;
qya.close;
qya.sql.clear;
qya.sql.add('select * from qxb where role=''总经理''');
qya.open;
i := 1;
while not qya.Eof do
begin
btnArr[i].Caption := qya.fieldbyname('an').asstring;
btnArr[i].Visible := True;
inc(i);
if (i>10) then Break;
qya.Next;
end;
end;
var
i:integer;
begin
for i:=1 to 10 do
TButton(Self.FindComponent('Btn'+(intTostr(i)))).Visible := False;
with qya do
begin
close;
sql.text:='select * from qxb where role=''总经理''';
open;
i:=1;
while not Eof do
begin
with TButton(Self.FindComponent('Btn'+(intTostr(i)))) do
begin
caption:=fieldbyname('an').asstring;
Visible := True;
end;
Next;
inc(i);
end;
end;
end;
var
i: Integer;
btnArr: array [1..10] of TButton;
begin
for i := 0 to ControlCount - 1 do
begin
if Controls[i] is TButton then
btnArr[i+1] := TButton(Controls[i]);
end;
qya.close;
qya.sql.clear;
qya.sql.add('select * from qxb where role=''总经理''');
qya.open;
i := 1;
while not qya.Eof do
begin
btnArr[i].Caption := qya.fieldbyname('an').asstring;
btnArr[i].Visible := True;
inc(i);
if (i>10) then Break;
qya.Next;
end;
end;
var
i: Integer;
btnArr: array [1..10] of TButton;
begin
for i := 0 to ControlCount - 1 do
begin
if Controls[i] is TButton then
btnArr[i+1] := TButton(Controls[i]);
end;
qya.close;
qya.sql.clear;
qya.sql.add('select * from qxb where role=''总经理''');
qya.open;
i := 1;
while not qya.Eof do
begin
btnArr[i].Caption := qya.fieldbyname('an').asstring;
btnArr[i].Visible := True;
inc(i);
if (i>10) then Break;
qya.Next;
end;
end;
用Action 是楼主权限没有定义好