本帖最后由 lixiaolong 于 2011-4-5 10:20 编辑
回复 1# duyan
看看这个可以不?$var = IniReadSection(@DesktopDir & '\main.ini', "main")
$address = '韩国'
For $i = 1 To $var[0][0]
If $var[$i][1] = $address Then
$i += 1
MsgBox(4096, "", $var[$i][1] & @CRLF & $var[$i + 1][1] & "岁" & @CRLF & $var[$i + 2][1])
$i += 1
EndIf
Next
main.ini[main]
address0=韩国
name1=刘德华
age1=44
sex1=男
address1=香港
name2=宋慧乔
age2=34
sex2=女
address2=韩国
name3=范冰冰
age3=32
sex3=女
address3=中国
name4=成龙
age4=58
sex4=男
address4=香港
name5=权相宇
age5=38
sex5=男
当练习吧#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $var = IniReadSection(@DesktopDir & '\main.ini', "main")
Global $address = '韩国'
GUICreate($address & '人', 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES)
GUISetBkColor(0x00E0FFFF) ; 设置背景色
$listview = GUICtrlCreateListView("姓名 |年龄|性别 ", 10, 10, 200, 150);,$LVS_SORTDESCENDING)
$button = GUICtrlCreateButton("查看选中项目的数据", 40, 170, 120, 20)
Global $item1 = GUICtrlCreateListViewItem("", $listview)
Global $item2 = GUICtrlCreateListViewItem("", $listview)
Global $item3 = GUICtrlCreateListViewItem("", $listview)
GUISetState()
address()
Do
$msg = GUIGetMsg()
Select
Case $msg = $button
MsgBox(0, "listview 项目", GUICtrlRead(GUICtrlRead($listview)), 2)
Case $msg = $listview
MsgBox(0, "listview", "被点击列的索引值 = " & GUICtrlGetState($listview), 2)
EndSelect
Until $msg = $GUI_EVENT_CLOSE
Func address()
Local $s = 1
For $i = 1 To $var[0][0]
If $var[$i][1] = $address Then
$i += 1
GUICtrlSetData(Eval('item' & $s), $var[$i][1] & '|' & $var[$i + 1][1] & '|' & $var[$i + 2][1])
$s += 1
$i += 4;这个可以去掉.
EndIf
Next
EndFunc ;==>address
如果想显示中国人只把 Global $address = '韩国' 改成 Global $address = '中国' 就可以了. |