Eureka
I am fine tuning a project and had enough to have troubles with a Listbox with the column widths / lack of Horizontal ScrollBar Time to make changes there !
So, I decided to only add the Horizontal ScrollBar. That requires a Boolean to be set ON (ScrollBarHorizontal) AND all the values of the ColumnWidths be a set of fixed values in Pixels.
Also, by default, Xojo set ColumnWidths to * followed by a number of commas (one for each column), so not what I wanted. [According to the documentation and my own research].
After deep thinking (a minute or two !), I wrote the following code:
[code]// How Many Fields in That RecordSet ?
Col_Cnt = SQLite_RS.FieldCount // Nil Check done earlier
// Set the number of columns
LB.ColumnCount = Col_Cnt
// Build the .ColumnWidths
String
Col_Width = “100” // 100 pixels wide, resizable “à la demande”
For i As Integer = 1 To Col_Cnt - 1
// Add an entry for each other column
Col_Width = Col_Width + “,100”
// To avoid infinite loop
If UserCancelled Then Exit
Next
// Apply It [useful to get the horizontal scrollbar]
LB.ColumnWidths = Col_Width[/code]
The code works fine. It is from a project where the data is extracted from a SQLite data base (thus SQLite_RS.FieldCount
).
If your project do things differently, just replace that command with a variable that holds the number of Columns for your data.
Do not forget to set the ColumnResizable
property to ON (if not already the case).