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:
Quote
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
[code](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[/code]
Quote from: Fred Tomke on April 10, 2008, 10:13:26 AM
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.
Ok, I will check your example in an hour, I have to bring my kids to bed first.
Fred
Quote from: Fred Tomke on April 10, 2008, 10:21:08 AM
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
Quote from: Fred Tomke on April 10, 2008, 10:29:27 AM
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
Thank you Fred!