OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: dayange on January 14, 2008, 09:07:09 PM

Title: Problem about opemdcl grid control
Post by: dayange on January 14, 2008, 09:07:09 PM
I am trying to use grid control, but I don't know how to get the value of a specified cell in gird control,
for example, if the cell type is set to AcadColor or Dropdown?

Would you please give me some example code?

And how to set default value for Dropdown cell in grid?
Title: Re: Problem about opemdcl grid control
Post by: BazzaCAD on January 14, 2008, 10:42:48 PM
Hello dayange & welcome to the team.
First have a look at the "Examples" folder under your OpenDCL install folder (usually C:\Program Files\OpenDCL Studio\Examples).
Drag the "_MasterDemo.LSP" file into your Acad window for an easy walk through of all the project. Most importantly have a look at the "GRID" project. It will show you how to pre-load the control, I.E. your Dropdown cell.
Second, when you're in the editor right-click on the grid and select "Intelligent Help". This will give you all the properties & methods for that control.
Have a looks at:
(dcl_Grid_AddColumns)
(dcl_Grid_AddRow)
(dcl_Grid_AddString)

(dcl_Grid_GetItemText)
(dcl_Grid_GetRowItems)

Hope this helps & let us know how you're doing & if you need any more help.
Title: Re: Problem about opemdcl grid control
Post by: Fred Tomke on January 15, 2008, 12:42:39 AM
Hello dayange,

I use opendcl grid control very often.
In some cases I use it in combination with a database.
The largest dialog I created with the grid control was a systemvariable manager - there are very different types of data. And all of them can be present in the grid.

The values you put in the grid, must be strings in any case, even the original values are numbers.
Maybe I can help furthermore when you give me more details.

Regards, Fred
Title: Re: Problem about opemdcl grid control
Post by: dayange on January 15, 2008, 02:55:12 AM
Thanks Fred, and thanks BazzaCAD.
I have gotten a row's list by (dcl_Grid_GetRowItems).

Moreover, My quesstions are:
1. how to set default value for AcadColor cell in grid?
   I set "Red" or other integer number by dcl_Grid_AddString, but the control cannot
   display the correct color. What should I do?

2. When I add a ComboBox(type is Colors) in Form, without adding any code, the list program
   will shutdown my Autocad 2006 at runtime--No alert, no message. What happened? How to solve it?
Title: Re: Problem about opemdcl grid control
Post by: Fred Tomke on January 15, 2008, 07:56:49 AM
Good catch, dayange,

1. I already know about color issues in grid control, I already send a list with grid issues (especially with colors) to Owen.

2. I don't know about issues in color combobox. Do you mean color combobox within the grid? Or as seperate combobox on the form?

Regards, Fred
Title: Re: Problem about opemdcl grid control
Post by: BazzaCAD on January 15, 2008, 03:26:28 PM
Quote from: dayange on January 15, 2008, 02:55:12 AM
Thanks Fred, and thanks BazzaCAD.
I have gotten a row's list by (dcl_Grid_GetRowItems).

Moreover, My quesstions are:
1. how to set default value for AcadColor cell in grid?
   I set "Red" or other integer number by dcl_Grid_AddString, but the control cannot
   display the correct color. What should I do?

2. When I add a ComboBox(type is Colors) in Form, without adding any code, the list program
   will shutdown my Autocad 2006 at runtime--No alert, no message. What happened? How to solve it?


#1 Try this:
(dcl_Grid_SetItemStyle Grid_Dcl-1_grid1
    nRow [as Integer]
    nCol [as Integer]
    nStyle [as Integer]
   {Optional} nData1  [as Integer]
   {Optional} nData2 [as Integer]
   {Optional} sString [as Integer])

See the Intelligent Help fro more info...
Note:The style change only governs the behavior of the cell and what happens when the user clicks on the cell.

For example if you set the style 33 - Linetype Cell, the current selection for the linetype must be correctly set in the dcl_Grid_AddString or dcl_Grid_AddRow functions. The item may not be changed to correctly display one of the listed items.


#2, Sound's like a bug, and when I just tried to load the Misc demo in 2006 it did crash (ran fine 2008). Bug reported:
https://sourceforge.net/tracker/index.php?func=detail&aid=1872452&group_id=187950&atid=923363 (https://sourceforge.net/tracker/index.php?func=detail&aid=1872452&group_id=187950&atid=923363)

Title: Re: Problem about opemdcl grid control
Post by: owenwengerd on January 16, 2008, 09:43:29 PM
I don't have time to test right now, but you might try using (dcl_Grid_SetItemImage) function to set a color in the color dropdown.  Likewise, try (dcl_Grid_GetItemImage) to get the current selection.  I think this will work because the "image index" value is used as the current selection index for combo style cells. :)
Title: Re: Problem about opemdcl grid control
Post by: JMack on January 20, 2008, 10:51:36 PM
Hi dayange,

BazzaCAD got it right with dcl_Grid_SetItemStyle.  This dcl function will allow you to set the colors when the form initializes.

When you add the row don't provide any data for the columns except the first one.
(setq iRowIndex (dcl_Grid_AddRow Project1_Form1_Grid1 "Row 1"))
Save the row index so you can setup the default values for the row with the proper data.

To add a an AcadColor index do this.
(dcl_Grid_SetItemStyle Project1_Form1_Grid1 iRowIndex iColumnIndex iCellStyleIndex iAcadColorIndex)

This will add a magenta cell to row 1 column 2:
(dcl_Grid_SetItemStyle Project1_Form1_Grid1 1 2 30 6)

Hope that helps you out when you work with AcadColor Cells.  I'm not sure about setting default data, but it could be related to dcl_Grid_SetItemStyle.

Cheers, JM




Title: Re: Problem about opemdcl grid control
Post by: dayange on January 21, 2008, 02:22:56 AM
Thanks everyone.
I got it.