TheSwamp
Code Red => Visual DCL Programming => AutoLISP (Vanilla / Visual) => OpenDCL => Topic started by: cadplayer on February 22, 2017, 02:11:52 AM
-
(defun odcl:fillDataGrid(<Control> lst) ; <Control>... Form2/Dialog1/datagrid1
; Remove / clean all columns from datagrid before add
(repeat (setq count (dcl-grid-getcolumncount <Control>))
(dcl-Grid-DeleteColumn <Control> (setq count (1- count))))
; Add new columns with name
(if (setq count (length lst) c 0) ; c...column r... row
(repeat count
(setq r 0)
(dcl-Grid-InsertColumn <Control> c (car (nth c lst)) 0 100 )
(dcl-Grid-SetCellStyle <Control> r c 1)
(dcl-Grid-SetCellText <Control> r c (car (nth c lst)))
(setq r (1+ r))
(setq c (1+ c)))
)
)
(https://dl.dropboxusercontent.com/u/174474939/CADforen/PlotDialog.png)
Hello!
I have little trouble with set Text (strings) in define cell from dataGrid.
My example shows I want set all LayoutsItems after selected Drawing which names displays in columnheader and separate cell.
May I do wrong in my code upp. this implementation give nil:
(dcl-Grid-SetCellText <Control> r c (car (nth c lst)))
What I have to do?
-
Take a look, I get always nil in method "dcl-Grid-SetCellText"
https://www.screencast.com/t/UUe5HUrGec2W (https://www.screencast.com/t/UUe5HUrGec2W)
-
Sorry solved !
Mistake was in I forget add rows before add cell values. Works like this:
(defun odcl:fillDataGrid(<Control> lst / i count r c lyCount lyNames) ; <Control>... Form2/Dialog1/datagrid1
; Remove / clean all columns from datagrid before add
(repeat (setq count (dcl-grid-getcolumncount <Control>))
(dcl-Grid-DeleteColumn <Control> (setq count (1- count))))
; Add rows standard 15 rows!
(repeat (setq i 15)
(dcl-Grid-InsertRow
<Control>; Form2/Dialog1/datagrid1
(setq i (1- i)) ; intRow [als Long] {intColumn0ImageIndex [als Integer]}
""; strColumn0Label [als String] {strColumn1Label [als String] strColumn2Label [als String]} ...
)
)
; Add new columns with name
(if (setq count (length lst) c 0) ; c...column r... row
(repeat count
(setq r 0)
(dcl-Grid-InsertColumn <Control> c (car (nth c lst)) 0 100 )
(setq lyCount (length (cadr (nth c lst)))
lyNames (reverse (mapcar 'car (cadr (nth c lst)))))
(repeat lyCount
(dcl-Grid-SetCellStyle
<Control> ; Form2/Dialog1/datagrid1
r ; intRow [als Long]
c ; intColumn [als Long]
1 ; intStyle [als Integer]
)
(dcl-Grid-SetCellText
<Control>; Form2/Dialog1/datagrid1
r ; intRow [als Long]
c ; intColumn [als Long]
(nth (setq lyCount (1- lyCount)) lyNames) ; strLabel [als String]
)
(setq r (1+ r))
)
(setq c (1+ c)))
)
)