if
checkbox1.checked:= true thencheckbox1.caption:='lock'
combobox1.Enabled:=false
else
combobox1.Enabled:=true;如上代码...我愿意是:当checkbox1控件为选中状态时,它的名字就为lock,并且将combobox1改为未激活状态。
可为什么老是在then那里报错啊。
我怎么也看不出来是哪里出错了
向各位求助。谢谢!
checkbox1.checked:= true thencheckbox1.caption:='lock'
combobox1.Enabled:=false
else
combobox1.Enabled:=true;如上代码...我愿意是:当checkbox1控件为选中状态时,它的名字就为lock,并且将combobox1改为未激活状态。
可为什么老是在then那里报错啊。
我怎么也看不出来是哪里出错了
向各位求助。谢谢!
begin
end
去复习下语法吧
begin
checkbox1.caption:='lock'
combobox1.Enabled:=false ;
end
else
combobox1.Enabled:=true
这样的写法,语法是没错了,但是。使用的时候能顺利嘛?我好像以前试过这样的写法,达不到目的,checkbox怎么点都选不中,我自己的写法如下:(用一个变量来控制)var
m:integer;
begin
if m=1 then
begin
checkbox1.caption:='lock';
combobox1.Enabled:=false ;
m:=0;
end else if m=0 then
begin
combobox1.Enabled:=true;
m:=1;
end;
end;
第二句视为else
要求:
当checkbox1控件为选中状态时,它的名字就为lock,并且将combobox1改为未激活状态。
否则的话,CHECKBOX1的名字为unlock,COMBOBOX1为激活状态....
上面是我没有说清楚
begin
if
checkbox1.Checked then
combobox1.enabled:=false
else
combobox1.enabled:=true;
if checkbox1.Checked then checkbox1.Caption:='unlock '
else
checkbox1.Caption:='lock ' ;
end;end.
麻烦高手们帮我把以上的代码看有没有办法优化一下,不胜感激!
begin
checkbox1.caption:='lock';
if checkbox1.checked then
begin
checkbox1.caption:='unlock';
checkbox1.enabled:=false;
end else
checkbox1.enabled:=true;
end;
if checkbox1.Checked
then checkbox1.Caption:='unlock '
else checkbox1.Caption:='lock ';
combobox1.enabled:=not heckbox1.Checked;
2 没有begin...end
begin
checkbox1.caption:='lock' ;
combobox1.Enabled:=false ;
end
else
combobox1.Enabled:=true;
楼主很强,很久未见楼主这般。。的了
begin
checkbox1.caption:='lock' ;
combobox1.Enabled:=false ;
end
else
combobox1.Enabled:=true;
checkbox1.checked:= true then 这是赋值 不是判断
时间的确花的太久了些,不过达到目的了procedure TForm1.CheckBox1Click(Sender: TObject);
begin
checkbox1.Caption:='unlock';
if checkbox1.Checked = true then
begin
checkbox1.Caption:='unlock';
combobox1.Enabled:=false;
end else
begin
checkbox1.Caption:='lock';
combobox1.Enabled:=true;
end
end;end.十分感谢大家的回答,更感谢大家的批评,这样更让我在出差的途中看DELPHI的书想到这个不会打瞌睡跟据tonylll兄的思路想出来的答案,所以选他的答案虽然不是理由,但是事实,不知道大家有没有一天到晚出差(在车上)有时还要连续上24小时班的经历(比如前天和昨天),有时下班早点又要处理家里和店里的事 只是因为自己的爱好想学门语言而捡起6年以前丢掉的东西从头开始学,有时的确会因为基础差而犯一些各位高手看起来很可笑的错误,希望大家批评中给以于指出,给于我更多动力.
谢谢大家!
锁定:http://cid-e4055a18739ae1a9.skydrive.live.com/self.aspx/.Public/delphi/sd.JPG
解锁:http://cid-e4055a18739ae1a9.skydrive.live.com/self.aspx/.Public/delphi/js.JPG