I have a modal form with a GridControl.
If the form has the OnSize event ON the GridControl fields are not populating ( except for the first column)
This applies if either (dcl_Grid_FillList .... OR (dcl_Grid_AddRow ... are used.
I've tried to set a global flag to stop resizing during initializing but have had no sucess.
For the attached, toggle the form OnSize event on to see the problem.
Regards
...
This is now fixed for the next build (which is waiting for the next Bricscad beta to be released).
Thanks Owen.
I've just arrived at home now, so don't have source, but ..
I also had issues with the
(dcl_Grid_CalcColumnWidth <CONTROL> Label [as String])
and
(dcl_Grid_SetColumnWidth <CONTROL> Column [as Long] Width [as Long])
The resulting column was about 1/4 as wide as it should have been.
If you need I'll post code tomorrow.
//-----------
Any idea on timeframe for the release ?
As I recall, CalcColumnWidth does not account for the cell image or non-standard cell contents. I expect a new Bricscad beta either this week or next. If it goes too long, I'll try to undo the changes I made and release a new build that supports the current beta.
Owen,
There were no images or non-standard content in the cells. I was using the sample posted, trying to achieve a compact dialog.
Can you upload a version the demonstrates the problem?
sure
added : on WinXP SP3 AC2010Mechanical
Replace the initialize event code with this :
;;-------------------------------------------------------
;;
(defun c:Props_Main_OnInitialize (/ )
;;| Set the Label TitleText |;
(dcl_Control_SetCaption Props_Main_Label (car PropsData))
;;| Set the Column Header Names |;
(dcl_Control_SetColumnCaptionList Props_Main_Grid (cadr PropsData))
;;
(setq GridData (cadddr PropsData)
RowCount (length GridData)
CellStyle (caddr PropsData)
RowIndex 0
)
;;
(dcl_Control_SetColumnStyleList Props_Main_Grid (List 0 CellStyle))
(dcl_Grid_FillList Props_Main_Grid GridData)
;;
;;
(dcl_Control_SetHeight Props_Main (+ 85 (* RowCount 24)) )
(setq headerWidths (mapcar '(lambda (x) (dcl_Grid_CalcColumnWidth Props_Main_Grid x))
(cadr PropsData)
)
;; test various values
col1 (dcl_Grid_CalcColumnWidth Props_Main_Grid "Column")
col2 (dcl_Grid_CalcColumnWidth Props_Main_Grid "Value")
col1x (dcl_Grid_CalcColumnWidth Props_Main_Grid "TEST567890")
col2x (dcl_Grid_CalcColumnWidth Props_Main_Grid "123")
)
(dcl_Control_SetColumnWidthList Props_Main_Grid headerWidths)
(prompt
(strcat "\nheaderWidths :" (VL-PRIN1-TO-STRING headerWidths)))
(princ)
)
;;-------------------------------------------------------
;;
The values returned are
headerWidths :(35 27)
and the col1 cells don't populate.
The CalcColumnWidth function is intended for use with cells within the grid, not the header cells as you're assuming in the sample code. Since the header cells use a larger font, I don't know whether you can reliably scale for those. When used for the normal grid content, it looks like you need to add at least 1 pixel to account for the column divider.
Sorry, I don't understand your response.
Your first column is a header column, so the header cell layout causes the calculated width to be incorrect. You can cheat by adding and/or multiplying the calclated width by some factor. That may or may not be reliable. I did a quick test, and the second column works fine at a width of (+ 1 (dcl_Grid_CalcColumnWidth Props_Main_Grid "First Value")).
I needed to double the value returned from the dcl_Grid_CalcColumnWidth to make the text visible for both columns.
I tried to double click on the header divider to change the column width ... works fine
Then I changed the okClicked event function to
;;-------------------------------------------------------
;;
(defun c:Props_Main_ok_OnClicked (/)
(prompt (strcat "\nNew headerWidths :"
(VL-PRIN1-TO-STRING (dcl_Control_GetColumnWidthList Props_Main_Grid))
)
)
)
but it appears to only return the initial column width ... it does not report the changes.
Regards
I also moved the cell population code to the end of the OnInitialize Function
;;-------------------------------------------------------
;;
(defun c:Props_Main_OnInitialize (/)
;;| Set the Label TitleText |;
(dcl_Control_SetCaption Props_Main_Label (car PropsData))
;;
(setq GridData (cadddr PropsData)
RowCount (length GridData)
CellStyle (caddr PropsData)
RowIndex 0
)
;;
(dcl_Control_SetColumnStyleList Props_Main_Grid (List 0 CellStyle))
;;
;;
(dcl_Control_SetHeight Props_Main (+ 85 (* RowCount 24)))
(setq headerWidths (mapcar '(lambda (x) (dcl_Grid_CalcColumnWidth Props_Main_Grid x))
(cadr PropsData)
)
)
(dcl_Control_SetColumnWidthList Props_Main_Grid (list 70 54)) ;headerWidths)
;; (dcl_Control_SetWidth Props_Main (+ 70 54 25))
;;| Set the Column Header Names |;
(dcl_Control_SetColumnCaptionList Props_Main_Grid (cadr PropsData))
(dcl_Grid_FillList Props_Main_Grid GridData)
;; (prompt (strcat "\nheaderWidths :" (VL-PRIN1-TO-STRING headerWidths)))
(princ)
)
;;-------------------------------------------------------
;;