Support Center

Rearrange columns

Donald Adams Dec 01, 2012 11:38AM EST

Delphi 7

When I rearrange the columns to display the them in the order I want and then run the program it goes back to the default column order. Is there a way to lock them in the new position and widths?

4 Data Techniques Responses and 4 Community Responses

Up -1 Rated Down
Donald Adams  Data Techniques Employee Dec 01, 2012 02:38PM EST

Also, if I uncheck the columns they still appear when I run the program.

Up -1 Rated Down
DTI Support  Data Techniques Employee Dec 03, 2012 09:51AM EST

Hi,

You will need to persist the ColName and ClWidth properties in your app code and then when the control is reloaded you'll need to set them to the values you obtained when your app shutdown.

Thanks for your interest in our products and please let us know if you have any questions.

Sincerely,
Sean
Data Techniques Support

Up -2 Rated Down
Donald Adams  Data Techniques Employee Dec 03, 2012 10:45AM EST

Can you show me some example code? Or point some out to me that is in the samples. Can I change the display name for a column?

Up 1 Rated Down
DTI Support  Data Techniques Employee Dec 03, 2012 10:47AM EST

Hi Donald,

The VB 6 Sample code we ship with the install shows this functionality. Let me know if you have any questions about it.

You can change the data thats displayed in a given column but you cannot change the Header Text or Column Label at this time.

John
Data Techniques Support

Up -1 Rated Down
Donald Adams  Data Techniques Employee Dec 03, 2012 03:36PM EST

I'm not a VB programmer. I have looked at the .bas files and do not see or recognize what is controlling the columns. Which files do I need to view? Am I going to have to find VB6 program to open the files to see what you are talking about?

Up -1 Rated Down
DTI Support  Data Techniques Employee Dec 03, 2012 03:37PM EST

HI Donald,

One sec and I will paste the relevant code for you....

Sean

Up -4 Rated Down
DTI Support  Data Techniques Employee Dec 03, 2012 05:12PM EST

Hi Donald,

OK, so here's some VB code that saves the current column settings, you would want to call this when the form, is being unloaded:

Global Const MAX_HDRITEMS = 21 ' 22 - 1

' Save the column Widths
For I = 0 To MAX_HDRITEMS
WritePrivateProfileString "Columns", Str$(I), Trim$(Str$(FaxMan1.ColWidth(I))), "faxtst.ini"
WritePrivateProfileString "ColumnHdrs", Str$(I), FaxMan1.ColName(I), "faxtst.ini"
Next I


and here's some code to restore those setting:


For I = 0 To MAX_HDRITEMS
'sets all columns 10 char wide
FaxMan1.ColWidth(I) = GetPrivateProfileInt("Columns", Str$(I), 10, "faxtst.ini")
'defines the order of the columns, as per the faxtst.ini
If GetPrivateProfileString("ColumnHdrs", Str$(I), "", tmp, 255, "faxtst.ini") Then
FaxMan1.ColName(I) = Trim$(tmp)
End If
Next I

This code saves the settings to a private app ini file but of course you could store it whereever you wish.

Let me know if you have any questions.
Sean

Up -4 Rated Down
Donald Adams  Data Techniques Employee Dec 03, 2012 05:50PM EST

Thank you ...just what I needed.

This question is closed to new answers.

Contact Us