一。

 

View Code
 //从ini加载权限列表
  ImportPostList:
=TStringList.Create;
  
try
    ImportPostList.LoadFromFile(DBModule.exeFilepath
+'ini\QuanX.ini');
    
if ImportPostList.Count>0 then
    
begin
      
for  i:=0 to ImportPostList.Count-1 do
      
begin
        TempStr:
=ImportPostList.Strings[i];
        TempList:
=TStringList.Create;
        
try
         TempList:
=FPNSplit(TempStr,#61); //如果是类似name=value的形式就不用分隔,直接用names,values属性得到相关值
           
if TempList.Count>=2 then
           
begin
              
with lvXuanKXM.Items.Add do begin
              Caption:
=IntToStr(lvXuanKXM.Items.Count);
              SubItems.Add(TempList.Strings[
0]);
              SubItems.Add(TempList.Strings[
1]);
              
end;
           
end;
        
finally
          TempList.Free;
        
end;
      
end;
    
end;
  
finally
    ImportPostList.Free;
  
end;

二。TListView的names,values属性

ini文件:

1=登记考生
2=权限管理
3=登记补考
4=系统参数管理

View Code
//加载管理员类型和权限 从ini文件和数据库
  ImportPostList:
=TStringList.Create;
  
try
    ImportPostList.LoadFromFile(DBModule.exeFilepath
+'ini\QuanX.ini');
    
if ImportPostList.Count>0 then
    
begin
      
while not qryQuanX.Eof do   //循环数据库
      
begin
        
with lvGuanLYQX.Items.Add do
        
begin
          Caption:
=IntToStr(lvGuanLYQX.Items.Count);
          SubItems.Add(qryQuanX.Fields[
1].Value);
          SubItems.Add(
string(qryQuanX.Fields[2].Value));
            
for I := 0 to ImportPostList.Count - 1 do
            
begin
              
if  ImportPostList.Names[i]=string(qryQuanX.Fields[2].Value) then
              
begin
                SubItems.Add(
ImportPostList.Values[ImportPostList.Names[i]]);
              
end;
            
end;
        
end;
        qryQuanX.Next;
      
end;
    
end;
  
finally
    ImportPostList.Free;
  
end;

 

posted on 2011-09-14 08:54  cnby  阅读(366)  评论(0编辑  收藏  举报