Author Topic: Problems with (dcl-Grid-SetCellText <Control>  (Read 4612 times)

0 Members and 1 Guest are viewing this topic.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Problems with (dcl-Grid-SetCellText <Control>
« on: February 22, 2017, 02:11:52 AM »
Code: [Select]
(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)))
      )
    )

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?


cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Problems with (dcl-Grid-SetCellText <Control>
« Reply #1 on: February 23, 2017, 11:45:55 AM »
Take a look, I get always nil in method "dcl-Grid-SetCellText"
https://www.screencast.com/t/UUe5HUrGec2W

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Problems with (dcl-Grid-SetCellText <Control>
« Reply #2 on: February 23, 2017, 01:19:18 PM »
Sorry solved !

Mistake was in I forget add rows before add cell values. Works like this:
Code: [Select]
(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)))
      )
    )