Can't get dcl_grid_addrow to work.

Started by Kelie · 2008-04-10 17:04 UTC · 11 replies · SMF topic #282

Hello,

I have a two-column grid and I'm using function below to fill in some data, but it doesn't work.


(defun c:MODVAR_frmMain_OnInitialize (/)
  (dcl_grid_addstring MODVAR_frmMain_grdVar
      "Name1\tValue1"
      "\t"
  )
  (dcl_grid_addstring MODVAR_frmMain_grdVar
      "Name2\tValue2"
      "\t"
  )
)


After I did a search in this forum. I tried the following and still didn't work.


(defun c:MODVAR_frmMain_OnInitialize (/)
  (setq iRowIndex1 (dcl_grid_addrow MODVAR_frmMain_grdVar "Row 1"))
  (setq iRowIndex2 (dcl_grid_addrow MODVAR_frmMain_grdVar "Row 2"))
)


What did I miss? Thanks.

Hi Kelie,

please try


(defun c:MODVAR_frmMain_OnInitialize (/)
  (setq iRowIndex1 (dcl_grid_addrow MODVAR_frmMain_grdVar (list "Row 1")))
  (setq iRowIndex2 (dcl_grid_addrow MODVAR_frmMain_grdVar (list "Row 2")))
)
I've found this in the intelligent help:


AutoLISP Syntax:
(Setq rValue (dcl_Grid_AddRow Untitled_Dialog1_Datenblatt1
(list 
Optional nImageIndex ... [as Integer]
sText [as String]
Optional sColText1 sColText2 sColText3 ... [as String])))


Fred
Finally,

If you want to add a full row take

(defun c:MODVAR_frmMain_OnInitialize (/)
  (setq iRowIndex1 (dcl_grid_addrow MODVAR_frmMain_grdVar (list "Col 1" "Col2")))
  (setq iRowIndex2 (dcl_grid_addrow MODVAR_frmMain_grdVar (list "Col 1" "Col2")))
)


If you want to add a row using only the value of first column you can also use:


(defun c:MODVAR_frmMain_OnInitialize (/)
  (setq iRowIndex1 (dcl_grid_addstring MODVAR_frmMain_grdVar "Row 1"))
  (setq iRowIndex2 (dcl_grid_addstring MODVAR_frmMain_grdVar "Row 2"))
)



Now we got it  :)

Fred
author=Fred Tomke link=topic=282.msg1248#msg1248 date=1207847606 wrote:
Hi Kelie,

please try


(defun c:MODVAR_frmMain_OnInitialize (/)
  (setq iRowIndex1 (dcl_grid_addrow MODVAR_frmMain_grdVar (list "Row 1")))
  (setq iRowIndex2 (dcl_grid_addrow MODVAR_frmMain_grdVar (list "Row 2")))
)



Thanks Fred. It didn't work. I attached the dcl and lsp file.

Attachments
Ok, I will check your example in an hour, I have to bring my kids to bed first.

Fred
author=Fred Tomke link=topic=282.msg1252#msg1252 date=1207848068 wrote:
Ok, I will check your example in an hour, I have to bring my kids to bed first.

Fred


Sure Fred. No rush. And thanks for your help.
Yeah, enabling OnInitialize event will be your solution  ;D

Fred
author=Fred Tomke link=topic=282.msg1254#msg1254 date=1207848567 wrote:
Yeah, enabling OnInitialize event will be your solution  ;D

Fred


That was a dumb mistake! Thanks a lot Fred.
More questions on grid:

1. Can I set different background color for columns?
2. Can I set certain columns to be read-only?

Thanks!
Hi Kelie

1. Yes, you can: define an alternate color and change alternate orientation (see pic below).
2. Not directly. There is a row header. This is not editable. In other cases you set the cell style to 0. Then it is not editable.

Fred
Attachments
Thank you Fred!