一个由ABCDEF组成的字符串,可能的结果如:
ABC
ABCD
AB
ABCDEF
ABCD
ACD
ABEF
...这个由六个字符组成的字符串中每个字符对应一个edit控件,如:
A 对应控件 EDIT1
B 对应控件 EDIT2
C 对应控件 EDIT3
D 对应控件 EDIT4
E 对应控件 EDIT5
F 对应控件 EDIT6问题:
在一个文本框(strEdit)中输入上述字符串中的任何一组时,点击按钮能够将对应的EDIT控件的背景颜色同时改变?
求教老师
ABC
ABCD
AB
ABCDEF
ABCD
ACD
ABEF
...这个由六个字符组成的字符串中每个字符对应一个edit控件,如:
A 对应控件 EDIT1
B 对应控件 EDIT2
C 对应控件 EDIT3
D 对应控件 EDIT4
E 对应控件 EDIT5
F 对应控件 EDIT6问题:
在一个文本框(strEdit)中输入上述字符串中的任何一组时,点击按钮能够将对应的EDIT控件的背景颜色同时改变?
求教老师
解决方案 »
- delphi 画布问题
- 招聘兼职:上海大型印刷企业招聘ERP开发人员(delphi7+sqlserver+cxgrid+fastreport)
- guolvguolv(guolvguolv)请来拿分(100)_1!(版主请等他拿了分再删)
- 紧急求助!!关于在一个文件中存储多种记录格式的数据,解决后立即给分!!!
- 请问有什么控件能生成条码???????急!!!!
- 请问一句select
- 高分请教:如何解决"BLOB has been modified"问题
- Indy Client中的IdTelnet怎样截获返回信息,请高手赐教
- !!!技术招标:将16进制话单文件转换后入库开发项目
- 如何使用流的方法写入控件的信息,并且用流的方法读出控件信息呢?
- 初学者提问:下面的代码哪里错了?
- 求一算法,关于SQL表 和 TreeView!
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
A: TEdit;
B: TEdit;
C: TEdit;
edt: TEdit;
btn1: TButton;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.btn1Click(Sender: TObject);
var
Comp:TComponent;
begin
Comp:=FindComponent(edt.Text);
if (Comp <> nil) and (Comp is TEdit) then
TEdit(Comp).Color:=clSkyBlue ;
end;end.
经测试,您的代码一次只能输入一个字符选中一个Edit控件,我想是输入一组字符,如ABC能够同时改变三个Edit控件的背景色,如何做呢?
procedure TForm1.btn1Click(Sender: TObject);
var
Comp:TComponent;
I:Integer;
begin
for I:=1 to Length(edt.Text) do
begin
Comp:=FindComponent(Copy(edt.Text,I,1));
if (Comp <> nil) and (Comp is TEdit) then
TEdit(Comp).Color:=clSkyBlue ;
end;
end;
var
str: string;
begin
str:= trim(strEdit.text);
for i:= 0 to length(str) - 1 do
(FindComponent(edit+inttostr(ord(str[i+1])-64)) as tedit).color:= clred;
end;
未测,一般能行
procedure TForm1.Button1Click(Sender: TObject);
var
str: string;
i: integer;
begin
str:= 'AC';
for i:= 0 to length(str) - 1 do
(FindComponent('edit'+inttostr(ord(str[i+1])-64)) as tedit).color:= clred;
end;
刚测,可以了