请问一下的delphi程序是什么意思,谢谢
procedureTfrmCreep.Button1Click(Sender:TObject);procedureChangeItem(AComboBox:TComboB...
procedure TfrmCreep.Button1Click(Sender: TObject);
procedure ChangeItem(AComboBox:TComboBox);
var
I:integer;
AStrings:array of String;
begin
if AComboBox.Items.Indexof(AComboBox.text)>=0 then
setlength(AStrings,AComboBox.Items.Count)
else
setlength(AStrings,AComboBox.Items.Count+1);
AStrings[0]:=AComboBox.text;
if AComboBox.Items.Indexof(AComboBox.text)>=0 then
begin
AComboBox.Items.Delete(AComboBox.Items.Indexof(AComboBox.text));
AComboBox.text:=AStrings[0];
end;
if AComboBox.Items.Count>=1 then
begin
for I:=1 to AComboBox.Items.Count do
AStrings[I]:=AComboBox.Items[I-1];
end;
AComboBox.Items.Clear;
for I:=0 to High(AStrings) do
AComboBox.Items.Add(AStrings[I]);
if AComboBox.Items.Count >= 51 then
AComboBox.Items.Delete(50);
end; 展开
procedure ChangeItem(AComboBox:TComboBox);
var
I:integer;
AStrings:array of String;
begin
if AComboBox.Items.Indexof(AComboBox.text)>=0 then
setlength(AStrings,AComboBox.Items.Count)
else
setlength(AStrings,AComboBox.Items.Count+1);
AStrings[0]:=AComboBox.text;
if AComboBox.Items.Indexof(AComboBox.text)>=0 then
begin
AComboBox.Items.Delete(AComboBox.Items.Indexof(AComboBox.text));
AComboBox.text:=AStrings[0];
end;
if AComboBox.Items.Count>=1 then
begin
for I:=1 to AComboBox.Items.Count do
AStrings[I]:=AComboBox.Items[I-1];
end;
AComboBox.Items.Clear;
for I:=0 to High(AStrings) do
AComboBox.Items.Add(AStrings[I]);
if AComboBox.Items.Count >= 51 then
AComboBox.Items.Delete(50);
end; 展开
2个回答
2012-06-07 · 知道合伙人软件行家
关注
展开全部
通过阅读代码,我觉得 procedure ChangeItem(AComboBox:TComboBox) 过程的作用,是当你在下拉列表框的锋誉编辑框中,输入罩基蔽某个列表中不存在的文本时,会自动将这个文本添加到下拉框中。
以下是详细注释:
procedure TfrmCreep.Button1Click(Sender: TObject);
procedure ChangeItem(AComboBox:TComboBox);
var
I:integer;
AStrings:array of String;
begin
//如果当前输入的文本在AComboBox下拉列表中存在(不存在),则修改AStrings的数组大小
if AComboBox.Items.Indexof(AComboBox.text)>=0 then
setlength(AStrings,AComboBox.Items.Count)
else
setlength(AStrings,AComboBox.Items.Count+1);
AStrings[0]:=AComboBox.text;
//如果索引到下拉列表输入框当前输入的文本在下拉列表中存在,则删除该项
if AComboBox.Items.Indexof(AComboBox.text)>=0 then
begin
AComboBox.Items.Delete(AComboBox.Items.Indexof(AComboBox.text));
AComboBox.text:=AStrings[0];
end;
//如物州果AComboBox的列表项总数>=1,则将AComboBox的列表项复制到AStrings
if AComboBox.Items.Count>=1 then
begin
for I:=1 to AComboBox.Items.Count do
AStrings[I]:=AComboBox.Items[I-1];
end;
//清除AComboBox列表项,然后将AStrings的内容添加到AComboBox列表项
AComboBox.Items.Clear;
for I:=0 to High(AStrings) do
AComboBox.Items.Add(AStrings[I]);
//如果AComboBox列表项总数>51,则删除第50项
if AComboBox.Items.Count >= 51 then
AComboBox.Items.Delete(50);
end;
以下是详细注释:
procedure TfrmCreep.Button1Click(Sender: TObject);
procedure ChangeItem(AComboBox:TComboBox);
var
I:integer;
AStrings:array of String;
begin
//如果当前输入的文本在AComboBox下拉列表中存在(不存在),则修改AStrings的数组大小
if AComboBox.Items.Indexof(AComboBox.text)>=0 then
setlength(AStrings,AComboBox.Items.Count)
else
setlength(AStrings,AComboBox.Items.Count+1);
AStrings[0]:=AComboBox.text;
//如果索引到下拉列表输入框当前输入的文本在下拉列表中存在,则删除该项
if AComboBox.Items.Indexof(AComboBox.text)>=0 then
begin
AComboBox.Items.Delete(AComboBox.Items.Indexof(AComboBox.text));
AComboBox.text:=AStrings[0];
end;
//如物州果AComboBox的列表项总数>=1,则将AComboBox的列表项复制到AStrings
if AComboBox.Items.Count>=1 then
begin
for I:=1 to AComboBox.Items.Count do
AStrings[I]:=AComboBox.Items[I-1];
end;
//清除AComboBox列表项,然后将AStrings的内容添加到AComboBox列表项
AComboBox.Items.Clear;
for I:=0 to High(AStrings) do
AComboBox.Items.Add(AStrings[I]);
//如果AComboBox列表项总数>51,则删除第50项
if AComboBox.Items.Count >= 51 then
AComboBox.Items.Delete(50);
end;
追问
谢谢您,给了这么详细的解答
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询