Retrieving Grid Control Contents

Started by Matt W, July 09, 2007, 05:34:11 AM

Previous topic - Next topic

Matt W

I've got a grid control in a project that I populate with search results (see image).  I'm using the following code to extract the 1st, 2nd & 3rd values (there will always be something in a cell so a null value is not an issue)

   (Setq rValue (dcl_Grid_GetRowItems MyBlox_Form1_GridSearchResults nRow))
   (setq X1 (car rValue))
   (setq X2 (cadr rValue))
   (setq X3 (caddr rValue))


So the question I have is this:  Is there another way of going about this using some of the functions in ODCL or a "preferred" way?  What I'm doing right now is working just fine.  I just wanted to see if maybe I could do it a little bit different or if there's a function in ODCL that I've missed that would do the same thing.

[attachment deleted by admin]

zeha

Quote from: Matt W on July 09, 2007, 05:34:11 AM
I've got a grid control in a project that I populate with search results (see image).  I'm using the following code to extract the 1st, 2nd & 3rd values (there will always be something in a cell so a null value is not an issue)

   (Setq rValue (dcl_Grid_GetRowItems MyBlox_Form1_GridSearchResults nRow))
   (setq X1 (car rValue))
   (setq X2 (cadr rValue))
   (setq X3 (caddr rValue))


So the question I have is this:  Is there another way of going about this using some of the functions in ODCL or a "preferred" way?  What I'm doing right now is working just fine.  I just wanted to see if maybe I could do it a little bit different or if there's a function in ODCL that I've missed that would do the same thing.

Hello Matt,

Ther are many way,s to do this

(setq i 0)
(mapcar '(lambda(item)(set (read (strcat "X" (itoa i))) item)(setq i (1+ i)))
(dcl_Grid_GetRowItems GRID_Dcl-1_grid1 nRow))


Set the symbol X1 X2 X3 Xn etc.. to the first element, second element and so on.
(equal to your code) for sofar as i now the fasted way.

(setq i 0)
(foreach item (dcl_Grid_GetRowItems GRID_Dcl-1_grid1 nRow)
(set (read (strcat "X" (itoa i))) item)(setq i (1+ i))
)


Similar to the first
Set the symbol X1 X2 X3 Xn etc.. to the first element, second eelement and so on.

  (setq rValue (dcl_Grid_GetRowItems GRID_Dcl-1_grid1 nRow))
  (setq X1 (nth 0 rValue))
  (setq X2 (nth 1 rValue))
  (setq X3 (nth 2 rValue))


Hope this help

Regards
Harrie