setting GRID Value

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
serge_girard
Posts: 3162
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

setting GRID Value

Post by serge_girard »

Hello,


In HMG doc I read: GRID (Multiselect): Numeric Array (Rows Selected).

After loading my Multiselect grid I want focus to be on the first row.

This doesn't work:

Code: Select all

SetProperty('Form_1', 'Grid_ADRESSEN', 'Value', {1,1} )
This give compile error:

Code: Select all

SetProperty('Form_1', 'Grid_ADRESSEN', 'Value', 1 )
So what is right syntax?

Serge
There's nothing you can do that can't be done...
User avatar
gfilatov
Posts: 1060
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: setting GRID Value

Post by gfilatov »

serge_girard wrote: Sun Oct 25, 2020 10:52 am Hello,


In HMG doc I read: GRID (Multiselect): Numeric Array (Rows Selected).

After loading my Multiselect grid I want focus to be on the first row.

This doesn't work:

Code: Select all

SetProperty('Form_1', 'Grid_ADRESSEN', 'Value', {1,1} )
This give compile error:

Code: Select all

SetProperty('Form_1', 'Grid_ADRESSEN', 'Value', 1 )
So what is right syntax?

Serge
Hello Serge,

Try

Code: Select all

SetProperty('Form_1', 'Grid_ADRESSEN', 'Value', {1} )
:arrow:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
serge_girard
Posts: 3162
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: setting GRID Value

Post by serge_girard »

Thanks Grigory but thisn't working either. Somewhere I have used it before .... but cannot find it and hard to search for: millions of grid and setproperty...

I will continue searching but if anyone has a hint..!

Serge
There's nothing you can do that can't be done...
User avatar
gfilatov
Posts: 1060
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: setting GRID Value

Post by gfilatov »

serge_girard wrote: Sun Oct 25, 2020 4:06 pm Thanks Grigory but thisn't working either. Somewhere I have used it before .... but cannot find it and hard to search for: millions of grid and setproperty...

I will continue searching but if anyone has a hint..!
Serge,

Please take a look for the following working sample:

Code: Select all

/*
* HMG Virtual Grid Demo
* (c) 2003 Roberto lopez
*/

#include "hmg.ch"

Function Main

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 450 ;
		HEIGHT 400 ;
		TITLE 'Hello World!' ;
		MAIN 

		DEFINE MAIN MENU
			DEFINE POPUP 'File'
				MENUITEM 'Change ItemCount' ACTION Form_1.Grid_1.ItemCount := Val(InputBox('New Value','Change ItemCount'))
			END POPUP
		END MENU

		@ 10,10 GRID Grid_1 ;
		WIDTH 400 ;
		HEIGHT 330 ;
		HEADERS {'Column 1','Column 2','Column 3'} ;
		WIDTHS {140,140,140};
		VIRTUAL ;
		ITEMCOUNT 100000 ;
		ON QUERYDATA QueryTest() MULTISELECT

	END WINDOW

	SetProperty('Form_1', 'Grid_1', 'Value', {1})

	CENTER WINDOW Form_1

	ACTIVATE WINDOW Form_1

Return Nil

Procedure QueryTest()

	This.QueryData := 'ர' + Str ( This.QueryRowIndex ) + ',' + Str ( This.QueryColIndex )

Return
:?:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: setting GRID Value

Post by edk »

gfilatov wrote: Sun Oct 25, 2020 4:46 pm Serge,

Please take a look for the following working sample:

Code: Select all

/*
* HMG Virtual Grid Demo
* (c) 2003 Roberto lopez
*/

#include "hmg.ch"

Function Main

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 450 ;
		HEIGHT 400 ;
		TITLE 'Hello World!' ;
		MAIN 

		DEFINE MAIN MENU
			DEFINE POPUP 'File'
				MENUITEM 'Change ItemCount' ACTION Form_1.Grid_1.ItemCount := Val(InputBox('New Value','Change ItemCount'))
			END POPUP
		END MENU

		@ 10,10 GRID Grid_1 ;
		WIDTH 400 ;
		HEIGHT 330 ;
		HEADERS {'Column 1','Column 2','Column 3'} ;
		WIDTHS {140,140,140};
		VIRTUAL ;
		ITEMCOUNT 100000 ;
		ON QUERYDATA QueryTest() MULTISELECT

	END WINDOW

	SetProperty('Form_1', 'Grid_1', 'Value', {1})

	CENTER WINDOW Form_1

	ACTIVATE WINDOW Form_1

Return Nil

Procedure QueryTest()

	This.QueryData := 'ர' + Str ( This.QueryRowIndex ) + ',' + Str ( This.QueryColIndex )

Return
:?:
Yes Grigory, but try to change the number of items to 1,000,000 and see how "quickly" the new value is set.

In my opinion, the LISTVIEWSETMULTISEL ( hWnd, aValue ) function, and basically its contents:

Code: Select all

n = ListView_GetItemCount( hWnd );

// CLEAR CURRENT SELECTIONS
    for (i = 0; i <n; i ++)
       ListView_SetItemState (hWnd, i, 0, LVIS_FOCUSED | LVIS_SELECTED);
runs too slow for large amounts of data.

I think it would be better to get the current values ​​before setting new values, and just clean them instead of clearing the whole list. :idea:
User avatar
gfilatov
Posts: 1060
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: setting GRID Value

Post by gfilatov »

edk wrote: Sun Oct 25, 2020 4:58 pm ...
I think it would be better to get the current values ​​before setting new values, and just clean them instead of clearing the whole list. :idea:
Hi,

You are right.

The speed of setting the new values in the multiselect Grid is very high after above modification :!:

Thank you very much for your suggestion :!:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
serge_girard
Posts: 3162
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: setting GRID Value

Post by serge_girard »

Hi guys, thank you but I think I did not made myself clear:

I have multiselect grid with few hundred lines (<1000), scrolling through the grid I select a 2 lines (COMPARE and change some value or whatever), save them and THEN
I want to save line-number of the grid, rebuild the grid with the changed values and direct to line I was.

Without multiselect this is possible (i've done before) so the focus has to be set on the previous line.

Code: Select all

// simple grid, x is row selected
SetProperty('Form_1', 'Grid_ADRESSEN', 'Value', x )    // this works 

/* documentation says:
GRID (Standard): Numeric (Row Selected).
GRID (Multiselect): Numeric Array (Rows Selected).	////////// this is the one I need
GRID (CellNavigation): Numeric Array (Row and col selected).
THIS I TRIED:
// SetProperty('Form_1', 'Grid_ADRESSEN', 'Value', {1,1} )
// SetProperty('Form_1', 'Grid_ADRESSEN', 'Value', {1} )
// SetProperty('Form_1', 'Grid_ADRESSEN', 'Value', (1) [1]  )  
// SetProperty('Form_1', 'Grid_ADRESSEN', 'Value', (1,1) )  
// SetProperty('Form_1', 'Grid_ADRESSEN', 'Value', i )   
SOME GIVE RTE, SOME COMPILE-ERROR AND SOME DO NOTHING....
*/
Hope this is clear enough....

Serge
There's nothing you can do that can't be done...
User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: setting GRID Value

Post by AUGE_OHR »

hi,

did you work with DBF or Array :?:
serge_girard wrote: Sun Oct 25, 2020 9:10 pm I want to save line-number of the grid, rebuild the grid with the changed values and direct to line I was.
after select file you got Items with

Code: Select all

   aItem := GetProperty( cForm, cObj, "Value" )
so i see no Problem to use

Code: Select all

   SetProperty( cForm, cObj, "Value", aItem )
AFTER refresh GRID

but "select" Item does not mean that Item is visible

---

in HBFM i use this

Code: Select all

PROCEDURE ItemMark( hGrid, nPos, nState, nMask )
   DEFAULT nState TO hb_BitOr( LVIS_SELECTED, LVIS_FOCUSED )
   DEFAULT nMask TO hb_BitOr( LVIS_SELECTED, LVIS_FOCUSED )

   LISTVIEW_SETITEMSTATE( hGrid, nPos, nState, nMask )
   ListView_EnsureVisible( hGrid, nPos, .T. )
RETURN
have fun
Jimmy
User avatar
serge_girard
Posts: 3162
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: setting GRID Value

Post by serge_girard »

Hi Jimmy

I work with array (loaded from DBF)

this is how I retrieve values from grid:

Code: Select all

aItem    := Form_1.Grid_Adressen.Item ( aSEL [1] )  
FOR Z := 1 TO 17
   xLBL1 := 'XBL1' + STRVALUE(Z)
   SetProperty('Form_1', xLBL1, 'Visible', TRUE )
   SetProperty('Form_1', xLBL1, 'Value', aItem [z] )
next
Then I make some changes to my dbf and reload changed data into grid, the same way as above.
But now I must scroll down and search for the record/lines where I was...

S
There's nothing you can do that can't be done...
User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: setting GRID Value

Post by AUGE_OHR »

hi,
serge_girard wrote: Mon Oct 26, 2020 7:35 am Then I make some changes to my dbf and reload changed data into grid, the same way as above.
But now I must scroll down and search for the record/lines where I was...
when you scroll down is Item "select" :?:

as i say LISTVIEW_SETITEMSTATE() just set "Select-Status" but do not "move"
you need ListView_EnsureVisible()
have fun
Jimmy
Post Reply