Hi, in the EGRID DEMO3, how can I maintaining the selection with the GRID in readonly mode?
Code: Select all
;******************************************************************************************
;'egrid4' editable grid control. By Stephen Rodriguez.
;******************************************************************************************
; DEMONSTRATION PROGRAM 3.
;******************************************************************************************
;This demo program sets up a simple egrid with some button type cells.
;It also shows how to dynamically colour cells as the user moves the selection around.
;******************************************************************************************
;XIncludeFile "egrid4.pb"
DisableExplicit
;*****************************************FONT DATA****************************************
Enumeration
#head1
#head2
#main
EndEnumeration
LoadFont(#main, "Arial", 9)
;SetGadgetFont(#PB_Default,FontID(#main))
;******************************************************************************************
Procedure.l MyCellCallBack(egrid, uMsg, *cellinfo.egridCellInfo)
Protected result
Select uMsg
Case #egrid_SelectCell
;Here we arrange for the selected row and column to be coloured blue.
;This requires a complete redraw of the egrid.
;The actual colouring has to be notified in the #egrid_FormatCell message below.
result=#True
RedrawWindow_(GadgetID(1), 0, 0, #RDW_INTERNALPAINT|#RDW_ERASE|#RDW_INVALIDATE)
Case #egrid_LosingFocus
;As part of colouring the selected row and column blue, we must arrange to clear these
;colours whenever the selection box is removed.
;The actual colouring has to be notified in the #egrid_FormatCell message below.
result=#True
RedrawWindow_(GadgetID(1), 0, 0, #RDW_INTERNALPAINT|#RDW_ERASE|#RDW_INVALIDATE)
Case #egrid_NotifyCellType
If *cellinfo\column=0
*cellinfo\celltype=#egrid_Button
EndIf
Case #egrid_FormatCell
If *cellinfo\row<>-1 And *cellinfo\row=egrid_SelectedRow(1); And *cellinfo\column=egrid_SelectedColumn(1)
*cellinfo\backcolour = $A5F4F9
ElseIf *cellinfo\row<>-1 And (*cellinfo\row=egrid_SelectedRow(1) Or *cellinfo\column=egrid_SelectedColumn(1))
;*cellinfo\backcolour = #Blue
;Debug Str(*cellinfo\row)+" "+Str(*cellinfo\column)
EndIf
Case #egrid_CellButtonClick
Debug "Clicked row "+Str(*cellinfo\row)
Default
result = #True ;This accounts for all messages we have decided not to process.
EndSelect
ProcedureReturn result
EndProcedure
;******************************************************************************************
;*************************************WINDOW + GADGET LIST*********************************
If OpenWindow(0,0,0,640,300,"egrid4 demo 3.",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_Maximize|#PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
;******************************************************************************************
;********************************************EGRID*****************************************
;Create an egrid with resizable columns.
egrid_CreateGrid(1, WindowWidth(0)/4, WindowHeight(0)/8, WindowWidth(0)/2, WindowHeight(0)/2,26,#egrid_GridLines, #egrid_ResizeColumnsTrue|#egrid_MultiLineText)
;******************************************************************************************
egrid_CreateCellCallback(1, @MyCellCallBack())
egrid_SetHeaderHeight(1, 26)
egrid_SetOptions(1, -1, #Black, 2, -1) ; gadgetnum, header border colour, selection border colour, selection border width, gridline colour
;********************************************TEXT GADGET***********************************
;***************************************ADD COLUMNS AND ROWS TO EGRID**********************************
egrid_AddColumn(1,0,"",60)
For b=1 To 4 ;50 columns.
egrid_AddColumn(1,b,"Col " + Str(b-1),60)
Next
For b=0 To 99 ; Add 10 rows.
egrid_AddRow(1,-1)
egrid_SetCellText(1, 0,b, "Row "+Str(b))
Next
;*****************************************EVENT LOOP***************************************
Repeat
EventID = WaitWindowEvent()
Select EventID
Case #PB_Event_Gadget
Select EventGadget()
EndSelect
EndSelect
Until EventID = #PB_Event_CloseWindow
EndIf
End
Thank you for this great lib!