Restore Grid Widths !

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
Claudio Ricardo
Posts: 367
Joined: Tue Oct 27, 2020 3:38 am
DBs Used: DBF, MySQL, MariaDB
Location: Bs. As. - Argentina

Restore Grid Widths !

Post by Claudio Ricardo »

Hi All !
I can autoadjust grid columns widths with " Control and + " from keyboard (Tip posted here)
and now i need restore at the values set in control definition... It is possible without redefine control ? How ?
This grid is in Main form... I try code below but don't work:

Code: Select all

Function Modulo_Reportes_Button_Widths_Action

Local aWidths := {70,70,70,70,200,90,90,70,70,90,90,90,90,200,40,40,40}   // <- original widths

	SetProperty ("Main", "Grid_Ventas", "Widths", aWidths)
	// Main.Grid_Ventas.Widths := aWidths
	// I try with above oop syntax but when compile say: Error E0030 Syntax error "syntax error at '.' "

Return Nil
Thanks in advance !!!
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Restore Grid Widths !

Post by AUGE_OHR »

hi,

you can use

Code: Select all

   nWide := LISTVIEW_GETCOLUMNWIDTH( hGrid, mCol - 1 )
and

Code: Select all

   LISTVIEW_SETCOLUMNWIDTH( hGrid, mCol - 1, nWide )
for nWide == -1 you get "optimal" Size for a Column
have fun
Jimmy
User avatar
Claudio Ricardo
Posts: 367
Joined: Tue Oct 27, 2020 3:38 am
DBs Used: DBF, MySQL, MariaDB
Location: Bs. As. - Argentina

Re: Restore Grid Widths !

Post by Claudio Ricardo »

Wonderful Jimmy !!!
Now I can toggle with button, between optimal and pre set widths without focus in grid !!!

Code: Select all

Function Modulo_Reportes_Button_Widths_Action

Local aWidths := {70,70,70,70,200,90,90,70,70,90,90,90,90,200,40,40,40}
Local hGrid := GetControlHandle ( "Grid_Ventas", "Main" )

	If LISTVIEW_GETCOLUMNWIDTH ( hGrid, HMG_Len (aWidths) - 1 ) < Atail (aWidths)

		For i := 1 To HMG_Len (aWidths)
		
			LISTVIEW_SETCOLUMNWIDTH ( hGrid, i - 1, aWidths [i] )
		
		Next

	Else

		For i := 1 To HMG_Len (aWidths)
		
			LISTVIEW_SETCOLUMNWIDTH ( hGrid, i - 1, -1 )
		
		Next

	EndIf

Return Nil
The last column is a one letter field, for this i use at refference...

Thank you very much for helping me quickly and for teaching me two functions I didn't know !!!!
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
Post Reply