table col's

dennishea

Active Member
Licensed User
Hi All.

When I start my prg I define my table col headers and widths. When I start saving data to the table and then make the table visiable to review the data everything is as I set it. When I exit prg I save table to csv file. Now when I start prg and load csv file the col headers are fine but the col widths are not what I programmed. They are to wide. When I load a csv file am I suppose to reformat the table?

edit:

sorry discovered table1.colwidth = :sign0161: :signOops:
 
Last edited:

willisgt

Active Member
Licensed User
If I correctly understand the behavior of tables: whenever you load a csv file into a table, the table contents (rows, columns) get wiped out and replaced by the contents of the file. Column widths will be reset back to the default value.

The solution would be to create a subroutine to handle the column widths. You can then call then routine at startup, and each time you load the file.


Gary
 

dennishea

Active Member
Licensed User
Thanks for the information willisgt. You are talking about using colwidth to reset the col width. Something like this.
Sub Reset_ColWidth

Table1.ColWidth("Name") = 40
Table1.ColWidth("x1") = 33
Table1.ColWidth("y1") = 33
Table1.ColWidth("x2") = 33
Table1.ColWidth("y2") = 33
Table1.ColWidth("r") = 33

End Sub
 

klaus

Expert
Licensed User
Longtime User
In my programs I save the column widths in a setup file with last values used, because the user can change the width. When he starts the program, the setup file is read and the column widths put in variables, so he will find the last values he set. After each load of a csv file you run Reset_ColWidth routine where you put the variables instead of the numeric values.

Best regards
 

willisgt

Active Member
Licensed User
Aha! Never thought of that... cool solution!

Gary

:sign0188:
 

dennishea

Active Member
Licensed User
Hi klaus.

Why would user want or need to adjust colwidth from the running prg. Up until now I never thought about that. Could you give a simple senario where this would apply. I admire and respect your programming skills so I know there is a reason. :sign0188:
 

klaus

Expert
Licensed User
Longtime User
In the Expense tracker and Wine cellar manager programs the user can add new names with different lengths, depending on what the user wants to see or focus on, he can adjust the column width to his convenience. Of course if you have data with fixed length you won't need the adjustment.

Best regards
 

dennishea

Active Member
Licensed User
Thank you klaus. Sometimes a need is hard to visualize without the need itself. Thank you again for taking the time. :)
 
Top