Hello everyone:
I add 40 items to GRID_1, and 10 items is visible at one time. There is a text to get the key from user. I wanna the item ,in which match the key to be on the first row of GRID_1. Tried several times and could find the way done. Please Help!
How to make specificed item on the first row?
Moderator: Rathinagiri
-
huangchenmin
- Posts: 157
- Joined: Mon Jun 07, 2010 2:24 am
- Rathinagiri
- Posts: 5482
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: How to make specificed item on the first row?
It is not implemented in HMG.
However it is possible to do that using an UDF.
Please add this code to your application and call this function whenever you change the value of the grid or even you can set 'on change makevaluefirstitem("Form_1","Grid_1")'
Tell me whether it works. It is taken from my very old application.
However it is possible to do that using an UDF.
Please add this code to your application and call this function whenever you change the value of the grid or even you can set 'on change makevaluefirstitem("Form_1","Grid_1")'
Tell me whether it works. It is taken from my very old application.
Code: Select all
function MakeValueFirstItem(cParentWindowName,cGridControlName)
local ControlHandle := GetControlHandle (cGridControlName,cParentWindowName)
local nValue := 0
nValue := GetProperty( cParentWindowName,cGridControlName,"VALUE" )
If nValue > 0
GridMakeFirst(ControlHandle,nValue)
Endif
return nil
#pragma BEGINDUMP
#include <windows.h>
#include <commctrl.h>
#include "hbapi.h"
HB_FUNC ( GRIDMAKEFIRST )
{
HWND hWnd1;
int value1,scroll1,top1;
POINT pt1,pt2;
hWnd1 = (HWND) hb_parnl (1);
value1 = (int) hb_parni (2);
top1 = SendMessage((HWND) hWnd1,LVM_GETTOPINDEX,(WPARAM) (int) 0,(LPARAM) (int) 0);
top1++;
SendMessage((HWND) hWnd1,LVM_GETITEMPOSITION,(WPARAM) (int) top1,(LPARAM) &pt1);
SendMessage((HWND) hWnd1,LVM_GETITEMPOSITION,(WPARAM) (int) value1,(LPARAM) &pt2);
scroll1 = pt2.y - pt1.y;
SendMessage((HWND) hWnd1,LVM_SCROLL,(WPARAM)(int) 0,(LPARAM)(int) scroll1);
}
#pragma ENDDUMP
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
-
huangchenmin
- Posts: 157
- Joined: Mon Jun 07, 2010 2:24 am
Re: How to make specificed item on the first row?
Thank you very much.rathinagiri wrote:It is not implemented in HMG.
However it is possible to do that using an UDF.
Please add this code to your application and call this function whenever you change the value of the grid or even you can set 'on change makevaluefirstitem("Form_1","Grid_1")'
Tell me whether it works. It is taken from my very old application.
Code: Select all
function MakeValueFirstItem(cParentWindowName,cGridControlName) local ControlHandle := GetControlHandle (cGridControlName,cParentWindowName) local nValue := 0 nValue := GetProperty( cParentWindowName,cGridControlName,"VALUE" ) If nValue > 0 GridMakeFirst(ControlHandle,nValue) Endif return nil #pragma BEGINDUMP #include <windows.h> #include <commctrl.h> #include "hbapi.h" HB_FUNC ( GRIDMAKEFIRST ) { HWND hWnd1; int value1,scroll1,top1; POINT pt1,pt2; hWnd1 = (HWND) hb_parnl (1); value1 = (int) hb_parni (2); top1 = SendMessage((HWND) hWnd1,LVM_GETTOPINDEX,(WPARAM) (int) 0,(LPARAM) (int) 0); top1++; SendMessage((HWND) hWnd1,LVM_GETITEMPOSITION,(WPARAM) (int) top1,(LPARAM) &pt1); SendMessage((HWND) hWnd1,LVM_GETITEMPOSITION,(WPARAM) (int) value1,(LPARAM) &pt2); scroll1 = pt2.y - pt1.y; SendMessage((HWND) hWnd1,LVM_SCROLL,(WPARAM)(int) 0,(LPARAM)(int) scroll1); } #pragma ENDDUMP
I will try and reply to you ASAP.
Best Regards
chen min