|
本帖最后由 delux2004 于 2020-4-10 20:59 编辑
求助各位大神,小弟想制作一个程序,窗体内有较多控件;目的是想根据ini内的key值来对控件进行循环赋值,采用循环嵌套,但不成功,请大神指教,谢谢!
以下是代码和截图:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 289, 305, 192, 124)
$Label1 = GUICtrlCreateLabel("姓名:", 32, 48, 40, 17)
$Name=GUICtrlCreateInput("", 85, 46, 121, 21)
$Label2 = GUICtrlCreateLabel("性别:", 32, 84, 40, 17)
$Sex =GUICtrlCreateInput("", 85, 82, 121, 21)
$Label3 = GUICtrlCreateLabel("年龄:", 32, 120, 40, 17)
$Age =GUICtrlCreateInput("", 85, 118, 121, 21)
$Label4 = GUICtrlCreateLabel("工号:", 32, 156, 40, 17)
$Number = GUICtrlCreateInput("", 85, 154, 121, 21)
$Label5= GUICtrlCreateLabel("基本工资", 32, 192, 52, 17)
$Wages =GUICtrlCreateInput("", 85, 190, 121, 21)
$Button1 = GUICtrlCreateButton("退出", 104, 248, 75, 25)
Data_Set() ;调用函数赋值
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
Exit
EndSwitch
WEnd
Func Data_Set()
Local $data[5][2]=[["姓名",$Name],["性别",$Sex],["年龄",$Age],["工号",$Number],["基本工资",$Wages]];将控件变量与控件名字合并为二维数组
Local $var=IniReadSection("C:\config.ini", "config");读取config内的参数
If @error Then
MsgBox(4096, "提示", "错误, 读取INI文件失败,请联系管理员!")
Else
For $i=1 To $var[0][0]
For $j= 0 To $data[0][0]
If $var[$i][0]=$data[$j][0] Then
GUICtrlSetData($data[$j][1],$var[$i][1])
Endif
Next
Next
Endif
Endfunc
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?加入
×
|