+ -
当前位置:首页 → 问答吧 → [delphi基础控件]TBXCombobox切换标签时出错,求助

[delphi基础控件]TBXCombobox切换标签时出错,求助

时间:2011-09-05

来源:互联网

如图,想做一个切换视图的功能

但是在切换时会报错,截图如下:


切换事件的代码如下:
Delphi(Pascal) code

procedure TForm1.tbxcmbxtmviewChange(Sender: TObject; const Text: string);
var
  l_tab  : TTabSheet;
  I : Integer;
  l_iniFile : Tinifile;
  l_name : string;
  l_gender : string;
  l_birthday : string;
  l_hobby : string;
  l_intro : string;
  l_age : integer;
  gendertemp : Integer;

begin
  if tbxcmbxtmview.Text = '树状视图' then
  begin
    if pgc1.ActivePageIndex <> -1 then pgc1.Free;
    RichTreeView.Show;
    mmo.Show;
    TBXSplitter.Show;
  end
  else
  begin
    RichTreeView.Hide;
    mmo.Hide;
    TBXSplitter.Hide;
    mmopgc.Show;
    pgc1.Show;
    strList := TStringList.Create;
    l_iniFile := TiniFile.Create(FileNames);
    l_iniFile.ReadSections(strList);
    for I := 0 to strList.Count - 1 do
    begin
      l_tab := TTabSheet.Create(pgc1);
      l_tab.Parent := pgc1;
      l_tab.Align := alClient;
      l_tab.Caption := strList[I];
      l_tab.PageControl := pgc1;
      mmopgc.Parent := l_tab;
      mmopgc.Align := alClient;
      mmopgc.Clear;

      l_name := l_iniFile.ReadString(strList[I], 'name', '');
      gendertemp := l_iniFile.ReadInteger(strList[I], 'gender', 0);
      if gendertemp = 0 then  l_gender := '' else l_gender := '';
      l_age := l_iniFile.ReadInteger(strList[I], 'ege', 0);
      l_birthday := l_inifile.ReadString(strList[I], 'birthday', '');
      l_hobby := l_inifile.ReadString(strList[I], 'hobby', '');
      l_intro := l_inifile.ReadString(strList[I], 'introduction', '');

      mmopgc.Clear;
      mmopgc.Lines.Add('姓名:'+l_name + #13#10 + '年龄:'+IntToStr(l_age)+ #13#10
                +'性别:'+l_gender +#13#10+ '生日: '+ l_Birthday + #13#10
                +'爱好:'+l_hobby +#13#10 + '介绍:'+ l_intro);
      mmopgc.Lines.Add(FileNames);
       l_inifile.Free;
    end;
    strList.Free;
    l_inifile.Free;
  end;
  
end;


请问各位,错在哪里?如何改正?

作者: hhkun0120   发布时间: 2011-09-05

Delphi(Pascal) code

     mmopgc.Lines.Add(FileNames);
       l_inifile.Free;


循环没结束,l_inifile被释放

这就是造成这个问题的原因。

作者: hhkun0120   发布时间: 2011-09-05

热门下载

更多