每次升级后,用户原先保存的列宽与列次序要重新设置,如何处理?
1、窗口AfterLoad
''======窗口表及控件数据设置提取=====
Dim e As Object = Args(0)
Dim pth As String = ProjectPath & "Syscm\用户设置\" '设置保存路径
If FileSys.DirectoryExists(pth) = False Then
FileSys.CreateDirectory(pth)
Else
Dim pthtxt As String = pth & e.Form.Name & ".txt"
If FileSys.FileExists(pthtxt) Then '判断指定的文件是否存在
Dim csts() As String = FileSys.ReadAllText(pthtxt,Encoding.Default).Split(chr(11)) '读取文本文件的内容
For Each st As String In csts
Dim stt() As String = st.Split("@")
If stt.Length >= 2 Then
If stt(0).Contains("Table") Then
e.Form.Controls(stt(0)).Table.SetColVisibleWidth(stt(1))
Else
e.Form.Controls(stt(0)).Value = stt(1)
'Vars("Chebox_sxs") = stt(1)
e.Form.Controls(stt(0)).WriteValue()
End If
End If
Next
End If
End If
2、AfterClose
''======窗口表及控件数据设置保存=====
Dim e As Object = Args(0)
Dim pth As String = ProjectPath & "Syscm\用户设置\"
If FileSys.DirectoryExists(pth) = False Then
FileSys.CreateDirectory(pth)
Else
Dim str As String = ""
Dim tbstr As String = ""
Dim txtstr As String = ""
For Each ctb As Object In e.Form.Controls
If Typeof ctb Is WinForm.Table Then '判断控件是否是Table
tbstr &= ctb.Name & "@" & e.Form.Controls(ctb.Name).Table.GetColVisibleWidth & chr(11) '返回一个字符串,包括显示的列及列宽信息
End If
Next
For Each ctb As Object In e.Form.Controls
If Typeof ctb Is WinForm.CheckedComboBox Then '判断控件是否是Table
If ctb.Name = "Chebox_sxs" Then
txtstr = "Chebox_sxs" & "@" & e.Form.Controls("Chebox_sxs").Value & chr(11)
Else
txtstr = ""
End If
End If
Next
str = tbstr & txtstr
Dim pthtxt As String = pth & e.Form.Name & ".txt"
FileSys.WriteAllText(pthtxt, str.Trim(chr(11)), False, Encoding.Default) '向文本文件中写入内容
End If
[此贴子已经被作者于2019/5/13 10:13:29编辑过]