Help with reading contents of a grid cell

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
bluebird
Posts: 154
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

Help with reading contents of a grid cell

Post by bluebird » Sun Mar 11, 2018 5:45 am

Dear Friends od g HMG

I have so much to learn. Recent problem is failure to read contents of a GRID that has been loaded with numbers

I have tried the following code to GET the values off the grid but they return Nils even though I can see the real
values by clicking on the cells.

The grid and the code to read values are shown below. As you can see I have tried different ways for b and c to no avail.

cimage is the name of an image control like cImage:="ImageNo"+str(nImageNo,1)

b:= setproperty("Win_2",cImage,"row",Getproperty("Full_Composite_Image","Grid_Assignment","value(nI,3)"))
c:= setproperty("Win_2",cImage,"col",Getproperty("Full_Composite_Image","Grid_Assignment","cellex(nI,3)"))

msgdebug("What is the values of a and b",a,b) // returns NIl,Nil



DEFINE GRID Grid_Assignment
ROW 120
COL 230
WIDTH 290
HEIGHT 340
VALUE Nil
WIDTHS {40,55,55,70,70 }
HEADERS {"Img","Row","Col","Width","Height"}
FONTNAME "Arial"
FONTSIZE 11
TOOLTIP ""
ONCHANGE Nil
ONGOTFOCUS Nil
ONLOSTFOCUS Nil
FONTBOLD .T.
ONDBLCLICK Nil
MULTISELECT .F.
ALLOWEDIT .T.
VIRTUAL .F.
DYNAMICBACKCOLOR Nil
DYNAMICFORECOLOR Nil
COLUMNWHEN Nil
COLUMNVALID Nil
COLUMNCONTROLS Nil
SHOWHEADERS .T.
CELLNAVIGATION .T.
NOLINES .F.
HELPID Nil
IMAGE Nil
JUSTIFY Nil
ITEMCOUNT MAXIMAGES
BACKCOLOR {192,192,192}
FONTCOLOR {0,193,97}
HEADERIMAGES Nil
ROWSOURCE Nil
COLUMNFIELDS Nil
ALLOWAPPEND .F.
ALLOWDELETE .F.
BUFFERED .F.
DYNAMICDISPLAY Nil
ONSAVE Nil
LOCKCOLUMNS 0
END GRID
Thanks for looking at my post

edk
Posts: 341
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Help with reading contents of a grid cell

Post by edk » Sun Mar 11, 2018 10:36 am

Try:

Code: Select all

b := setproperty ( "Win_2" , cImage , "row" , Getproperty ( "Full_Composite_Image" , "Grid_Assignment" , "value" , nI , 3 ) )
c := setproperty ( "Win_2" , cImage , "col" , Getproperty ( "Full_Composite_Image" , "Grid_Assignment" , "cellex" , nI , 3 ) )

bluebird
Posts: 154
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

Re: Help with reading contents of a grid cell

Post by bluebird » Mon Mar 12, 2018 6:37 pm

The solution for memvar c:=Getproperty ( "Full_Composite_Image" , "Grid_Assignment" , "cellex" , nI , 3 ) worked very well thanks edk

New surprise though! If I load the grid with sets of numeric memvars then use
Getproperty ( "Full_Composite_Image" , "Grid_Assignment" , "cellex" , nI , 3 ) )

I get back character values instead of the numeric ones that I loaded.

Can anyone explain why, and how I can get back the numbers instead of characters?

Thanks

User avatar
koke
Posts: 68
Joined: Wed Aug 21, 2013 3:54 pm
DBs Used: DBF, mySql, mariaDB

Re: Help with reading contents of a grid cell

Post by koke » Tue Mar 13, 2018 12:22 pm

you only want what's on each cell
have you try
theline := Win_2.Grid_Assignment.item(Win_2.Grid_Assignment.value)
it returns an array with the values of each row, and it doesent matters whitch type they are.
,___,
[O.o]
/)__)
-”–”-
KoKe

Post Reply