Hi. I have this code in my Query_Close of a form which has a grid on it called "iGridComposite":
Dim lCol As Long
For lCol = 1 To Me.iGridComposite.ColCount
Me.iGridComposite.ColVisible(lCol) = True
Next lCol
'
' Save column settings
SaveSetting "Demo_Restore_Layout", "LayoutStrings", "Col", Me.iGridComposite.LayoutCol
Call Log("Closing form" & frmPortfolioDiversification.iGridComposite.LayoutCol)
The For loop is an attempt to force all columns visible before I save the settings - just for troubleshooting this issue. For the record, I can see all the columns before I run this code. I do not hide any columns in my code.
I then save the settings and then immediately log those settings into a text log file.
I then open my log file and I see this:
0:15:41 PM: Closing form
1|Width|20|1|Order|1|1|Visible|1|2|Width|54|2|Order|2|2|Visible|1|3|Width|193|3|Order|4|3|Visible|1|4|Width|256|4|Order|5|4|Visible|1|
5|Width|42|5|Order|6|5|Visible|1|6|Width|30|6|Order|7|6|Visible|1|7|Width|35|7|Order|3|7|Visible|1|8|Width|37|8|Order|10|8|Visible|1|
9|Width|90|9|Order|11|9|Visible|1|10|Width|115|10|Order|12|10|Visible|1|11|Width|83|11|Order|13|11|Visible|1|12|Width|99|12|Order|14|12|Visible|1|
13|Width|77|13|Order|15|13|Visible|1|14|Width|96|14|Order|16|14|Visible|1|15|Width|97|15|Order|17|15|Visible|1|16|Width|71|16|Order|18|16|Visible|1|
17|Width|48|17|Order|19|17|Visible|1|18|Width|88|18|Order|8|18|Visible|1|19|Width|61|19|Order|9|19|Visible|1|
Note that all columns show Visible|1|
I also log the layoutcol string just after I perform the GetSetting function and it does not match what was saved. The form initialization code is below - pretty straight forward.
'
' Composite Grid
With frmPortfolioDiversification.iGridComposite
.BeginUpdate
.Header.UseXPStyles = False
.Header.BackColor = RGB(43, 57, 144)
.Header.ForeColor = RGB(255, 255, 255)
.Editable = False
.AllowSorting = False
.Header.DragCols = True
.UseXPStyles = False
.Header.Font.Bold = True
.Header.Flat = False
.AddCol sheader:=" " ' 1
.AddCol sheader:="Account" ' 2
.AddCol sheader:="Acct. Type" ' 3
.AddCol sheader:="Client Name" ' 4
.AddCol sheader:="Equity" ' 5
.AddCol sheader:="F/I" ' 6
.AddCol sheader:="Cash" ' 7
.AddCol sheader:="Type" ' 8
.AddCol sheader:="Disc/Non-Disc" ' 9
.AddCol sheader:="Trade Restrictions" ' 10
.AddCol sheader:="Custodian No" ' 11
.AddCol sheader:="Custodian Name" ' 12
.AddCol sheader:="Broker Code" ' 13
.AddCol sheader:="Broker Name" ' 14
.AddCol sheader:="Total Mkt Value" ' 15
.AddCol sheader:="Comm Rate" ' 16
.AddCol sheader:="Dis Pct" ' 17
.AddCol sheader:="U ST-G/L" ' 18
.AddCol sheader:="U LT-G/L" ' 19
.EndUpdate
End With
'
' Restore the column layout
frmPortfolioDiversification.iGridComposite.LayoutCol = GetSetting("Demo_Restore_layout", "LayoutStrings", "Col")
Call Log("Opening form" & frmPortfolioDiversification.iGridComposite.LayoutCol)
Here's what I get in the log file:
10:15:45 PM: Opening form
1|Width|90|1|Order|1|1|Visible|1|2|Width|150|2|Order|2|2|Visible|1|3|Width|61|3|Order|3|3|Visible|1|4|Width|180|4|Order|4|4|Visible|1|
5|Width|42|5|Order|5|5|Visible|0|6|Width|24|6|Order|6|6|Visible|0|7|Width|69|7|Order|7|7|Visible|1|8|Width|65|8|Order|10|8|Visible|1|
9|Width|61|9|Order|11|9|Visible|1|10|Width|46|10|Order|12|10|Visible|1|11|Width|38|11|Order|13|11|Visible|1|12|Width|51|12|Order|14|12|Visible|1|
13|Width|69|13|Order|15|13|Visible|1|14|Width|61|14|Order|16|14|Visible|1|15|Width|46|15|Order|17|15|Visible|1|16|Width|71|16|Order|18|16|Visible|0|
17|Width|48|17|Order|19|17|Visible|0|18|Width|62|18|Order|8|18|Visible|0|19|Width|61|19|Order|9|19|Visible|0|
Note that several columns are Visible|0| - 5, 6, 16, 17, 18, and 19.
I can confirm that the Visible|0| columns are in fact hidden as soon as the form and grid appear, and I haven't added any rows. I don't understand why the string I saved and the string I get back do not match.
Once I load the grid, the hidden columns become visible (I do not make them visible in the code where I load the grid, they just reappear). But if I try to move a column, then close the form and reopen it, I get the same results as above and the column I moved (once the grid loads) is back where it started.
Not sure what I'm doing wrong.
Thanks.
Troy
Edited by moderator
2018-11-28T11:05:38Z
|
Reason: Igor/10Tec: formatted code and log records