procedure TForm1.ComboBox1Change(Sender: TObject);
function NeedDropDown: Boolean;
begin
{该函数用于设置弹出下拉列表的条件}
Result := Pos('www.csdn', TComboBox(Sender).Text) = 1;
end;
begin
if NeedDropDown then begin
{在此进行下拉列表的整理(下拉之前)}
TComboBox(Sender).DroppedDown := True;//弹出下拉列表
end else begin
{在此进行下拉列表的整理或隐藏下拉列表}
end;
end;
procedure TFrmMain.Button1Click(Sender: TObject);
var
inif : TIniFile;
i, c : Integer;
h : TStrings;
begin
FrmURL := TFrmURL.Create(Application);
History := TStringList.Create;
h := TStringList.Create;
inif := TIniFile.Create('record.ini');
inif.ReadSection('Record',h);
if h.Count>10 then
c := 10
else
c := h.Count;
History.Clear;
for i := 0 to c-1 do
History.Add(inif.ReadString('Record',IntToStr(i),'无法读取 ini 文件'));
FrmURL.ComboBox1.Clear;
FrmURL.ComboBox1.Items.Assign(History);
h.Free;
if FrmURL.ShowModal=mrOk then
begin
History.Insert(0,FrmURL.ComboBox1.Text);
if History.Count>10 then
c := 10
else
c := History.Count;
for i := 0 to c-1 do
inif.WriteString('Record',IntToStr(i),History.Strings[i]);