grid dblclick

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

franco
Posts: 820
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

grid dblclick

Post by franco »

I am having trouble in grid with dblclick. My column 2 of grid is qty, which it must update a different table if changed so it must be locked.
I am trying to not allow double click on column 2.
I use on enter to make changes in the grid and in col 2 I must be able to lock the other file/record before allowing change. dblclick makes a mess in this case.
In the grid
on dblclick { if grid.value[2] = 2 no not allow double click ?

Thanks in advance..
All The Best,
Franco
Canada
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: grid dblclick

Post by mol »

You should use WHEN codeblock table, which controls which column is editable
franco
Posts: 820
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: grid dblclick

Post by franco »

Thanks Mol
I use WHEN but only with .T. or .F.
I see you can put code in the WHEN for a column, I did not know before.
Now I need to figure how to put code to see if I get a Lock then col 2 is .T. and after change it is .F.
All The Best,
Franco
Canada
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: grid dblclick

Post by mol »

You can use something like this:

Code: Select all

function GridWhenTest
return This.CellColIndex == 2
Or, you can put any action required before cell edition.
After that, you can use VALID codeblocks determining if everything is good
franco
Posts: 820
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: grid dblclick

Post by franco »

how can I find lastcharacterpressed() I cannot find driving me nuts
if get last = chr(13)
return .T.
else
return .F.
endif
All The Best,
Franco
Canada
User avatar
Claudio Ricardo
Posts: 367
Joined: Tue Oct 27, 2020 3:38 am
DBs Used: DBF, MySQL, MariaDB
Location: Bs. As. - Argentina

Re: grid dblclick

Post by Claudio Ricardo »

Hi... In Cli**er and Harbour have LastKey () Example:
If LastKey () = 13
Return .T.
Else
Return .F.
EndIf
Another (This can be used in code block):
Function EnterKeyPress // or other name
Return Iif ( LastKey () = 13 , .T. , .F. )
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
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: grid dblclick

Post by mol »

try to use piece of this code:

Code: Select all

	ch := HMG_GetLastCharacter(@hWnd)
	IF hWnd == GetControlHandle ("GridControlName","FormName")
		return if(asc(ch) == 13, .T., .F.)
	ENDIF
User avatar
AUGE_OHR
Posts: 2062
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: grid dblclick

Post by AUGE_OHR »

hi,

if you "press" a Key than use HMG_GetLastVirtualKeyDown()

Code: Select all

LOCAL xKey   := HMG_GetLastVirtualKeyDown()
   DO CASE
      CASE xKey == VK_RETURN
have fun
Jimmy
franco
Posts: 820
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: grid dblclick

Post by franco »

Thanks guys for all your help. I came up with 2 ways to make it work from your suggestions.
I only want to use ENTER key to change column 2 in grid.
In grid definition.
1:

Code: Select all

COLUMNWHEN { {||.T.}, {|| iIf(HMG_GetLastVirtualKeyDown() == 13, .T., .F.)}, {||.T.}, {||.T.}, {||.T.}, {||.T.}}
2:

Code: Select all

COLUMNWHEN { {||.T.}, {|| CHECK()}, {||.T.}, {||.T.}, {||.T.}, {||.T.}}
FUNCTION CHECK
	Local aCell, ch   := HMG_GetLastVirtualKeyDown()
	HMG_CleanLastVirtualKeyDown()
	aCell := form_1.Grid_1.value
	If ch == 13 .and. aCell[2] = 2 
	 	aCell[2] := 3
		form_1.Grid_1.value := aCell
		Return .T.
	Else
		form_1.Grid_1.value := aCell
		Return .F.
	Endif
RETURN
All The Best,
Franco
Canada
franco
Posts: 820
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: grid dblclick

Post by franco »

I am trying to find something that must be simple. I need not the value of grid but what the cell value is before save.
When linked to a table the before the save the cell value can be different from table. I AM HAVING TROUBLE FINDING THAT VALUE.
Also on change procedure always fires at least twice because when you enter cell it has change then you modify cell it has change.
I have created a public variable that in the change procedure I make the first change return to grid then process the second change.
All The Best,
Franco
Canada
Post Reply