Jimbo
How to make a Table forget its column configuration - solution
September 17, 2009 05:36AM
Hi,

WinDev AAF offers to move, resize, hide and unhide colums of a Table. But there is no easy way to return to the original column configuration. The code below allows for being added to all Tables (with the name 'Table', others have to bee adapted) in the System popup-menu as a menu-item of something like 'Reset Column Configuration':


TC,TX, TW, TD are int
TN is string

TC = TableCount(Table,toColumn)

FOR TX = 1 TO TC
	TN = TableEnumColumn(Table,TX)
	TableMoveColumn(Table,TN,TX)
	IF {"Table."+TN}..InitialVisible = True THEN
		{"Table."+TN}..Visible = True
		{"Table."+TN}..Width = {"Table."+TN}..InitialWidth
		TW += {"Table."+TN}..Width
	END
END

TD = Table..Width - TW - 18  // 18 ~= Width of vertical scrollbar of Table
FOR TX = 1 TO TC
	TN = TableEnumColumn(Table,TX)
	IF {"Table."+TN}..InitialVisible = True THEN
		{"Table."+TN}..Width += TD * {"Table."+TN}..AnchorRateWidth / 1000
	END
END


Note 1: I wasn't able to find the width of the vertical scrollbar of the table programmatically. Vertical scrollbars of my tables ('110 System') are 18 pixels in width ..

Note 2: to make the second part of the procedure work, take care that the original AnchorRateWidth of the visible colums add up to 100%

Note 3: In order to make this code even independent from the name of the Table ('Table') you'd have to experiment with PopupField(..) to recover the name of the Table. However, I find it easier to change the Table's name in code ..

Kind regards,
Guenter



Edited 1 time(s). Last edit at 12/13/2009 06:13PM by Jimbo.
Jimbo
Reset Column Configuration
December 12, 2009 11:38PM

Hi,

I enhanced the code a bit, it's independent of the Table control's name now.

You can find the code and some explanation (item 15) in the download section oft [www.windev.at]

And there's an example project for download!

see: [www.windev.at]

Kind regards,
Guenter

Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: