折腾了一天还是没有结果,头大中~~~~~~

tishineq 2004-01-14 10:36:52
stringgrid读取文本文件(评分汇总.file)。
程序在运行时(中途不关闭),添加修改功能都可实现。但是在程序退出,再重新运行时,对于选中的item在stringgrid中有对应项的情况会进行添加而不是修改操作!!



var
onerow:string;
statistics:tsringlist;
rownum:integer;

begin
onerow:=listbox1.items[listbox1.itemindex]+','+label1.Caption

//如果不存在评分汇总.file则创建。
if not FileExists('评分汇总.file') then statistics.SaveToFile('评分汇总.file');
statistics.LoadFromFile('评分汇总.file');
for rownum:=0 to statistics.count-1 do
begin
if comparetext(stringgrid.Cells[0,rownum],listbox1.items[listbox1.itemindex])=0 then
begin
statistics.Strings[rownum]:=onerow;//修改特定行
break;//跳出循环
end
//如果没有和listbox相匹配的项则添加一行
else if rownum=statistics.count-1 then
statistics.add(onerow);
end;
if statistics.count=0 then statistics.add(onerow);
statistics.SaveToFile('评分汇总.file');
statistics.Free;
end;
...全文
43 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
ekin 2004-01-15
  • 打赏
  • 举报
回复
o
xiangding 2004-01-15
  • 打赏
  • 举报
回复
你调用有问题吧,
上面的程序看不出问题来,, 你可否讲得明白一点?
搬运工木木 2004-01-15
  • 打赏
  • 举报
回复
字符比较或重新读入文件模块有问题
zth215 2004-01-15
  • 打赏
  • 举报
回复
关注
up
sunny518 2004-01-15
  • 打赏
  • 举报
回复
不明白你的意思。说清楚点好吗?
lgqTiger 2004-01-15
  • 打赏
  • 举报
回复
关注!
cma123 2004-01-15
  • 打赏
  • 举报
回复
up
tishineq 2004-01-15
  • 打赏
  • 举报
回复
运行时(中途不关闭),添加修改功能都可实现。但是在程序退出,再重新运行时,对于选中的item在stringgrid中有对应项的情况会进行添加而不是修改操作!!

不象是比较的问题,

关于“重新读入文件模块有问题”,应该怎样读入呢



hwkknd 2004-01-14
  • 打赏
  • 举报
回复
晚了困了,对你这个东东挺感兴趣…
UP一下,明天来研究……

5,388

社区成员

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

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