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

hhkun0120 2011-09-05 12:41:21
如图,想做一个切换视图的功能

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


切换事件的代码如下:

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;


请问各位,错在哪里?如何改正?
...全文
85 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
hhkun0120 2011-09-08
  • 打赏
  • 举报
回复
CSDN的图片显示是什么机制啊?
他是每次都读取本地文件吗,还是第一次加载后就传到了服务器上?
为什么现在看不到了。
给分先。[Quote=引用 5 楼 rainychan2009 的回复:]
图片看不到
[/Quote]
rainychan2009 2011-09-07
  • 打赏
  • 举报
回复
图片看不到
dmfssdut 2011-09-07
  • 打赏
  • 举报
回复
l_inifile.Free;
end;
strList.Free;
l_inifile.Free;
山东蓝鸟贵薪 2011-09-06
  • 打赏
  • 举报
回复
继续顶一下
hhkun0120 2011-09-06
  • 打赏
  • 举报
回复
没人回答吗?送分!
hhkun0120 2011-09-05
  • 打赏
  • 举报
回复

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

循环没结束,l_inifile被释放

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

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧