问题如下:
for x:=1 to j do
begin
for y:=1 to b do
begin
if checkbox1.checked then
begin
label1:=tlabel.create(self);
label1.parent:=image[x][y]
label2:=tlabel.create(self);
label2.parent:=image[x][y]
label1.caption:='adfd';
label2.caption:='asdfds';
end else begin
label1.caption:='';
label2.caption:='';
end;
end;
end; 现在界面上有两幅图像,当checkbox1.checked:=true时,两幅图像上都有label的值,但当checkbox1.checked:=false时,只有第二幅上的label没值,预想的结果是两幅图上的label都没值显示
各位帮忙试一下就知道了
for x:=1 to j do
begin
for y:=1 to b do
begin
if checkbox1.checked then
begin
label1:=tlabel.create(self);
label1.parent:=image[x][y]
label2:=tlabel.create(self);
label2.parent:=image[x][y]
label1.caption:='adfd';
label2.caption:='asdfds';
end else begin
label1.caption:='';
label2.caption:='';
end;
end;
end; 现在界面上有两幅图像,当checkbox1.checked:=true时,两幅图像上都有label的值,但当checkbox1.checked:=false时,只有第二幅上的label没值,预想的结果是两幅图上的label都没值显示
各位帮忙试一下就知道了
解决方案 »
- D2007的GetCapDevice改写为delphi2010
- 为什么在部分电脑中ListView高亮无法显示
- 请问如何把一些小图片存在sql server数据库里面?
- 高手来看看,一个关于ADO和SQL Server的问题!
- delphi7的代码转成delphi5该怎么转?(在线)
- 如何在程序一开始就选中Treeview中的某个子节点,而非根节点
- 公司被抵压,即将解散,Delphi+ASP程序员来求职
- 一个简单的问题(必有中谢哦!:))
- 大哥大姐们!如何用DELPHI显示GIF,只能用第三方控件吗?还有其它方法没?
- 如何用delphi+sql建立树形菜单+备注?各位帮帮忙啊,急!!!
- 菜问题——浏览器
- winnote文档收集管理软件1.2版正式发布(免费)工具软件,希望对大家有所帮助
begin
label1:=tlabel.create(self);
label1.parent:=image[x][y]
label2:=tlabel.create(self);
label2.parent:=image[x][y]
label1.caption:='adfd';
label2.caption:='asdfds';
end else begin
label1:=tlabel.create(self);
label1.parent:=image[x][y]
label2:=tlabel.create(self);
label2.parent:=image[x][y]
label1.caption:=''; //还没有创建
label2.caption:='';
end;
还是这样的
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
CheckBox1: TCheckBox;
Label1: TLabel;
Label2: TLabel;
procedure CheckBox1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.CheckBox1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if CheckBox1.Checked then
begin
Label1.Caption := 'Cheched' ;
Label2.Caption := 'Cheched' ;
end
else
begin
Label1.Caption := '' ;
Label2.Caption := '' ;
end;end;end.
begin
for y:=1 to b do
begin label1:=tlabel.create(self);
label1.parent:=image[x][y]
label2:=tlabel.create(self);
label2.parent:=image[x][y]
label1.caption:=''; //
label2.caption:=''; // if checkbox1.checked then
begin
label1.caption:='adfd';
label2.caption:='asdfds';
end else begin
label1.caption:='';
label2.caption:='';
end;
end;
end;
//这个... ,这儿的Image[x][y] : TImage 吗 ?
就像用反白这种处理方式,按一按钮,两幅图像同时反白,再按一下,两幅图像的反白效果同时消失。但现在是再按一下,只有第二幅的反白效果消失。我觉得是因为在进行上述操作后,x:=2,y:=2,就指向了第二幅图像。有没有什么办法?
begin
Label1.Caption := 'Cheched' ;
Label2.Caption := 'Cheched' ;
end
else
begin
Label1.Caption := '' ;
Label2.Caption := '' ;
end;
label1.parent:=image[x][y] ; 这可以吗 ?TWinControl ?
----------------
当checkbox1.checked:=true时,两幅图像都有label的值显示出来,但当checkbox1.checked:=false时,原本想两幅图像上的label的值都为空,但结果是第二幅中的label的值为空,第一幅中的值仍存在的------------------------------------------------------------------这样应该可以 :for x:=1 to j do
begin
for y:=1 to b do
begin label1:=tlabel.create(self);
label1.parent:=image[x][y]
label2:=tlabel.create(self);
label2.parent:=image[x][y]
label1.caption:=''; // 先置空
label2.caption:=''; // if checkbox1.checked then
begin
label1.caption:='adfd';
label2.caption:='asdfds';
end else begin
label1.caption:='';
label2.caption:='';
end;
end;
end;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;type
TForm1 = class(TForm)
CheckBox1: TCheckBox;
procedure CheckBox1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.CheckBox1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
Label1,Label2 : TLabel ;
begin Label1 := TLabel.Create(self) ;
Label1.Parent := Self ;
Label1.Left := 10 ;
Label1.Top := 20 ;
Label1.Caption := '' ; Label2 := TLabel.Create(Self) ;
Label2.Parent := Self ;
Label2.Left := 10 ;
Label2.Top := 40 ;
Label2.Caption := '' ; if CheckBox1.Checked then
begin
Label1.Caption := 'Cheched' ;
Label2.Caption := 'Cheched' ;
end
else
begin
Label1.Caption := '' ;
Label2.Caption := '' ;
end;
end;end.
应该是 lab1.parent:=image[x][y].parent;
因为现在它指向的是第二幅画中的两个label!
label1[x][y]:array [0..40]of array [0..40]of Tlabel;
label2[x][y]:array [0..40]of array [0..40]of Tlabel;
for x:=1 to j do
begin
for y:=1 to b do
begin
if checkbox1.checked then
begin
label1[x][y]:=tlabel.create(self);
label1[x][y].parent:=image[x][y]
label2[x][y]:=tlabel.create(self);
label2[x][y].parent:=image[x][y]
label1[x][y].caption:='adfd';
label2[x][y].caption:='asdfds';
end else begin
label1[x][y].caption:='';
label2[x][y].caption:='';
end;
end;
end;
unit Unit19;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;type
TForm1 = class(TForm)
CheckBox1: TCheckBox;
Image1: TImage;
Image2: TImage;
procedure CheckBox1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.CheckBox1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
Label1,Label2 : TLabel ;
begin Label1 := TLabel.Create(self) ;
Label1.Parent := Image1.Parent ;
Label1.Left := Image1.Left ;
Label1.Top := Image1.Top + 10 ;
Label1.Caption := '' ;
Label2 := TLabel.Create(Self) ;
Label2.Parent := Image2.Parent ;
Label2.Left := Image2.Left ;
Label2.Top := Image2.Top + 10 ;
Label2.Caption := '' ; if CheckBox1.Checked then
begin
Label1.Caption := 'Cheched' ;
Label2.Caption := 'Cheched' ;
end
else
begin
Label1.Caption := '' ;
Label2.Caption := '' ;
end;
end;end.
to wjlsmail(计算机质子) ( )
谢谢你的帮助。但我的image一定得用二维数组。我将另开贴感谢二位