I have been needing a grid gadget, so took a look at yours. It is
understandable and simple to use.
But, in trying to use the cells, I see that it doesn't always perform as
described. As an example, run the code below:
Code: Select all
; ************************************************************************
; ** DEMO CS-GRID V1.03 *** (c) 2005 Christian Walde-Sauer, 27.10.2005 ***
; ************************************************************************
; * Last Edit 07.11.2005 *
; * Demo-Routing for multiple Edit-Grid-Gadgets with easy implementation *
; ************************************************************************
; Additional information:
; - Contains no special Windows library commands, should be runable for windows/linux/macosx - actually no chance to test
; - Supports nearly all native Gadget commands
; - Multiple customizing commands (colors, designs, etc.)
; - Free to be used for own projects (mentioned in credits would be welcome), delivered as it is
; - Future plans:
; - Datainput by selection out of a list (source based on a SQL string with two columns)
; - Column-Sorting
; - Embedded sub-container for detailed information
wStyle = #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered
hWnd = OpenWindow(0, 0, 0, 800, 400, wStyle, "Terry's CS-Grid-Gadget")
If hWnd
CreateGadgetList(WindowID())
test = CSGridGadget(#PB_Any,10,10,743,300,10,5) ; Creates a CS-Grid-Gadget
CSGridGadget_SetAutoRedraw(test,-1) ; Turns off Auto-Redraw for Grid 1 for faster setup
CSGridGadget_SetColCaptionVisibility(test,1) ; Shows a column header (default empty caption)
CSGridGadget_SetColCaption(test,0,"String") ; Defines custom header Labels for all Columns
CSGridGadget_SetColCaption(test,1,"Long") ; Defines custom header Labels for all Columns
CSGridGadget_SetColCaption(test,2,"Float") ; Defines custom header Labels for all Columns
CSGridGadget_SetColCaption(test,3,"Formatted") ; Defines custom header Labels for all Columns
CSGridGadget_SetColCaption(test,4,"Percentage") ; Defines custom header Labels for all Columns
CSGridGadget_SetColCaption(test,5,"US Dollars") ; Defines custom header Labels for all Columns
CSGridGadget_SetColCaption(test,6,"User Fmt") ; Defines custom header Labels for all Columns
CSGridGadget_SetRowCaptionVisibility(test,1) ; Shows a row header (default numbered caption)
CSGridGadget_SetColWidth(test,2,100) ; Defines Column-Width for Column 2
CSGridGadget_SetColWidth(test,3,100) ; Defines Column-Width for Column 3
CSGridGadget_SetColWidth(test,5,100) ; Defines Column-Width for Column 5
CSGridGadget_SetColWidth(test,6,100) ; Defines Column-Width for Column 6
CSGridGadget_SetColDataType(test,0,0) ; Defines Output-Type to Text for Column 0
CSGridGadget_SetCellValue(test,0,0,"TESTING") ; Defines new Content for Cell C:0 R:0
CSGridGadget_SetColDataType(test,1,1) ; Defines Output-Type to Long Integer for Column 1
CSGridGadget_SetCellValue(test,1,0,"654924") ; Defines new Content for Cell C:1 R:0
CSGridGadget_SetColDataType(test,2,16) ; Defines Output-Type to Float for Column 2
CSGridGadget_SetCellValue(test,2,0,"139.6548") ; Defines new Content for Cell C:2 R:0
CSGridGadget_SetColDataType(test,3,17) ; Defines Output-Type to Formatted Fload, 2 decimals places
; CSGridGadget_SetColUserNumberFormat(test,3,"##,###,###.00") ; Defines User-Output-Type for Column 3
CSGridGadget_SetCellValue(test,3,0,"1221.105") ; Defines new Content for Cell C:3 R:0
CSGridGadget_SetColDataType(test,4,64) ; Defines Output-Type to Percentage, 4 decimals places
CSGridGadget_SetCellValue(test,4,0,"0.456789") ; Defines new Content for Cell C:3 R:0
CSGridGadget_SetColDataType(test,5,33) ; Defines Output-Type to US Dollars, 2 decimals places
CSGridGadget_SetColUserNumberFormat(test,5,"#######0.00") ; Defines User-Output-Type for Column 3
CSGridGadget_SetCellValue(test,5,0,"150286") ; Defines new Content for Cell C:3 R:0
CSGridGadget_SetColDataType(test,6,127) ; User defined Output-Type
;CSGridGadget_SetColUserNumberFormat(test,6,"#######0.00") ; Defines User-Output-Type for Column 3
CSGridGadget_SetCellValue(test,6,0,"1502.86") ; Defines new Content for Cell C:3 R:0
CSGridGadget_SetCellValue(test,2,1,"No Access") ; Defines new Content for Cell C:2 R:1
CSGridGadget_SetCellLockStatus(test,2,2,-16) ; Locks Cell C:2 R:2 for access (and input)
CSGridGadget_SetCellValue(test,3,3,"No Edit") ; Defines new Content for Cell C:3 R:3
CSGridGadget_SetCellLockStatus(test,3,3,-1) ; Locks Cell C:3 R:3 for input
CSGridGadget_SetAutoRedraw(test,1) ; Turns on Auto-Redraw for Grid 1 for faster setup
Repeat
main_EventID = WaitWindowEvent()
Select main_EventID
Case #PB_Event_SizeWindow
CSGridGadget_Resize(test,10,10,743,300) ; Resizes Grid 1
Default
CSGridGadget_EventHandling(main_EventID); Processes all Grid-Gadget events (for all CS-Grid-Gadgets)
EndSelect
Until main_EventID = #PB_Event_CloseWindow
CSGridGadget_FreeGadget(test) ; Removes the Grid with all sub-objects and frees memor, alternatively native command: RemoveGadget
End
EndIf
Col 1 - defined as a long. Documentation says it would be right justified. It isn't
Col 2 - defined as a float. Again, documentation says it would be right
justified. It isn't. It displays a rounded integer value for the float value
passed to it.
Col 3 - defined as formatted float. Documentation says it will be right
justified with 2 decimal places. And it does just that, but the value
displayed is not rounded properly.
Col 5 - defined as Currency USD. That works, but I couldn't find a way to
change the display format to US style with , (comma) as the thousand
separator and . (decimal) as the decimal place separator.
Every attempt I made to set the user number format resulted in incorrect
numbers displaying. Maybe just me.
You post above mentioned handling for column summarys, but I didn't
find that at all.
Your grid looks really good. A few tweaks and I could be happy with it.