如何将ini中的内容写入到listview中去?

wwjlucky 2003-08-30 05:07:13
rt,谢谢!
...全文
52 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
dyshadow 2003-08-31
  • 打赏
  • 举报
回复
你先定一下INI文件中的键值命名规则。
比如:
[User]
UserName1=abc
Password1=abc
UserName2=cde
Password2=cde

把USER作为一个表
把UserName Password作为字段
1 2 作为第N条记录

在程序中操作数组一样操作

不就好了?
读取INI用我给你的函数。
一点一点添加到LISTVIEW中。
wwjlucky 2003-08-30
  • 打赏
  • 举报
回复
在listview中的格式

字段1 字段2 字段3
A a 1
B b 2
C c 3
berylseabirdjnb 2003-08-30
  • 打赏
  • 举报
回复
每在ini中读一条记录就在listview中ListView_list.Items.Add;每读一个字段就在相应的listview记录上jiluji.Fields.Add;当然如果你已经规定了有几个字段,那就不用jiluji.Fields.Add了,只需jiluji.Fields[j].AsString就可以了。
wwjlucky 2003-08-30
  • 打赏
  • 举报
回复
超级猛料?!
dyshadow 2003-08-30
  • 打赏
  • 举报
回复
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Dim rtnValueA As Variant

Function WriteToIni(ByVal strFileName As String, ByVal strSectionName _
As String, ByVal strKeyName As String, ByVal strValue As String)
'将值写到INI文件中去
rtnValueA = WritePrivateProfileString(strSectionName, strKeyName, strValue, strFileName)
End Function
Function ReadFromIni(ByVal strFileName As String, ByVal strSectionName _
As String, ByVal strKeyName As String, ByVal strDefault As String)
Dim strOut As String * 255
'从INI文件中读取值
rtnValueA = GetPrivateProfileString(strSectionName, strKeyName, strDefault, strOut, 255, strFileName)
ReadFromIni = Trim(Replace(strOut, Chr(0), ""))
End Function
'---------------------------------------------------------------------------------
以上的两个函数,你自己用吧!
很简单的调用。
lovedata 2003-08-30
  • 打赏
  • 举报
回复
很容易的,找点儿例子看看就行了~
“超级猛料”里就有很详细的例子,改改就行了啊~

5,379

社区成员

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

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