Page 22 of 25
Posted: Wed Jan 17, 2007 11:44 pm
by srod
I nearly mentioned that you'd have a problem here, but you seemed adamant that the cell wouldn't be selected.
If the cell is selected, then the #egrid_cellUpdated message will NOT fire until the focus moves to another cell etc.
After all, the #egrid_cellUpdated message is intended to allow the developer to write changes to cells back to a database etc. Consequently the message is only sent when it is absolutely necessary, i.e. when it is very likely that the changes made to a cell are final. This is usually when the user selects another cell etc.
The only exceptions are CheckBox cells which are not selected. Changes to these have to be notified immediately.
At present it is not possible to be notified when a user clicks a checkmark on a cell which is selected. You have to wait until the user selects another cell.
The only real way around this is for me to introduce another CellCallback message.
Is this very important?
Posted: Wed Jan 17, 2007 11:59 pm
by ts-soft
srod wrote:
Is this very important?
This is required for my program. I will ever give information of count
selected checkboxes in first row.
This information also a wish from other users of my program, i hope you can
help me.
I can't count this every time without event, sometimes i have over 5000 rows
Posted: Thu Jan 18, 2007 12:05 am
by srod
Why not prohibit that first column from being selected? The checkmarks can then still be altered.
I must admit that, when I used your program, I did think it a little strange that you could select those cells in the first column.
If you look at demo program 7, you will see how to prevent the selection of such cells but also control cell navigation etc. I think it can work quite well.
However, if you insist (

), I will add an extra CellCallback message.
Posted: Thu Jan 18, 2007 12:35 am
by ts-soft
the source from example 7 works fine, but in my source, i can selected column 0
Code: Select all
egrid_CreateGrid(#egrid, 5, 5, 0, 0, 20, #egrid_AlwaysShowSelection, #egrid_CustomHeader | #egrid_ResizeColumnsTrue)
I don't know, what is missing
Code: Select all
Case #egrid_SelectCell
; If *cellinfo\column = 0
; If CountSelected() <> Count
; Count = CountSelected()
; SetWindowTitle(0, "Lib2PBImport - " + LibName + " [" + Str(CountSelected()) + " of " + Str(egrid_NumberOfRows(#egrid)) + " Functions selected]")
; EndIf
; result = #False
; EndIf
If *cellinfo\column = 0
Select *cellinfo\param
Case #egrid_LeftClick
egrid_MakeCellVisible(#egrid, 0, *cellinfo\row)
result = #False
Case #egrid_ShiftTab
If *cellinfo\row > 0
*cellinfo\row - 1
*cellinfo\column = egrid_NumberOfColumns(#egrid) - 1
Else
egrid_MakeCellVisible(#egrid, 0, *cellinfo\row)
result = #False
EndIf
Default
egrid_MakeCellVisible(#egrid, 0, *cellinfo\row)
*cellinfo\column = #True
EndSelect
EndIf
result = #True
RedrawWindow_(GadgetID(#egrid), 0, 0, #RDW_INTERNALPAINT|#RDW_ERASE|#RDW_INVALIDATE)
Posted: Thu Jan 18, 2007 12:44 am
by srod
It doesn't look like you've copied this code from demo 7 correctly.
Third line from the bottom:
is causing every selection to proceed. You need to move this to immediately below the Case #egrid_SelectCell.
Also, change *cellinfo\column = #True to *cellinfo\column = 1 as this is a column number rather than a boolean value.
Posted: Thu Jan 18, 2007 12:47 am
by ts-soft
okay, but doesn't work
i think this is the problem:
Code: Select all
Case #egrid_FormatCell
If Not *cellinfo\row = -1
*cellinfo\forecolour = 8421376
EndIf
If Not *cellinfo\row % 2
*cellinfo\backcolour = 14811135
EndIf
If *cellinfo\row<> - 1 And *cellinfo\row = egrid_SelectedRow(#egrid)
*cellinfo\backcolour = $A5F4F9
EndIf
Default
result = #True
Posted: Thu Jan 18, 2007 12:58 am
by srod
That works fine when pasted in demo 7.
Posted: Thu Jan 18, 2007 1:02 am
by srod
In the #egrid_SelectCell handler, you should remove the RedrawWindow_().
Posted: Thu Jan 18, 2007 1:05 am
by ts-soft
here the complett cellcallback
Code: Select all
Procedure.l CellCallBack(egrid, uMsg, *cellinfo.egridCellInfo)
Protected result, i
Static ENABLED, CDECL, Count = -1
Protected cbString.s
For i = 0 To 25
cbString + Str(i) + #LF$
Next
cbString + "26"
Select uMsg
Case #egrid_HeaderItemClick
Select *cellinfo\column
Case 0
ENABLED ! 1
For I = 0 To egrid_NumberOfRows(#egrid)
If Not ENABLED
egrid_SetCellText(#egrid, 0, i, "TRUE")
Else
egrid_SetCellText(#egrid, 0, i, "FALSE")
EndIf
Next
If CountSelected() <> Count
Count = CountSelected()
SetWindowTitle(0, "Lib2PBImport - " + LibName + " [" + Str(CountSelected()) + " of " + Str(egrid_NumberOfRows(#egrid)) + " Functions selected]")
EndIf
Case 4
CDECL ! 1
For I = 0 To egrid_NumberOfRows(#egrid)
If CDECL
egrid_SetCellText(#egrid, 4, i, "TRUE")
Else
egrid_SetCellText(#egrid, 4, i, "FALSE")
EndIf
Next
EndSelect
Case #egrid_InsertChar
Select *cellinfo\column
Case 0
result = #True
If CountSelected() <> Count
Count = CountSelected()
SetWindowTitle(0, "Lib2PBImport - " + LibName + " [" + Str(CountSelected()) + " of " + Str(egrid_NumberOfRows(#egrid)) + " Functions selected]")
EndIf
Case 2
Select *cellinfo\param
Case 0 To 48, 58 To 64, 91 To 94, 96, 123 To 255
result = #False
Default
result = #True
EndSelect
Case 5
result = #True
Case 3
If *cellinfo\param > 47 And *cellinfo\param < 58
result = #True
EndIf
EndSelect
Case #egrid_DeleteChar
result = #True
If *cellinfo\column = 0
If CountSelected() <> Count
Count = CountSelected()
SetWindowTitle(0, "Lib2PBImport - " + LibName + " [" + Str(CountSelected()) + " of " + Str(egrid_NumberOfRows(#egrid)) + " Functions selected]")
EndIf
EndIf
Case #egrid_CellUpdated
result = #True
If *cellinfo\column = 0
egrid_SetCellText(#egrid, 0, *cellinfo\row, *cellinfo\text)
If CountSelected() <> Count
Count = CountSelected()
SetWindowTitle(0, "Lib2PBImport - " + LibName + " [" + Str(CountSelected()) + " of " + Str(egrid_NumberOfRows(#egrid)) + " Functions selected]")
EndIf
EndIf
Case #egrid_SelectCell
; If *cellinfo\column = 0
; If CountSelected() <> Count
; Count = CountSelected()
; SetWindowTitle(0, "Lib2PBImport - " + LibName + " [" + Str(CountSelected()) + " of " + Str(egrid_NumberOfRows(#egrid)) + " Functions selected]")
; EndIf
; result = #False
; EndIf
If *cellinfo\column = 0
Select *cellinfo\param
Case #egrid_LeftClick
egrid_MakeCellVisible(#egrid, 0, *cellinfo\row)
result = #True
Case #egrid_ShiftTab
If *cellinfo\row > 0
*cellinfo\row - 1
*cellinfo\column = egrid_NumberOfColumns(#egrid) - 1
Else
egrid_MakeCellVisible(#egrid, 0, *cellinfo\row)
result = #False
EndIf
Default
egrid_MakeCellVisible(#egrid, 0, *cellinfo\row)
*cellinfo\column = 1
EndSelect
EndIf
result = #True
RedrawWindow_(GadgetID(#egrid), 0, 0, #RDW_INTERNALPAINT|#RDW_ERASE|#RDW_INVALIDATE)
Case #egrid_LosingFocus
result = #True
RedrawWindow_(GadgetID(#egrid), 0, 0, #RDW_INTERNALPAINT|#RDW_ERASE|#RDW_INVALIDATE)
Case #egrid_NotifyCellType
Select *cellinfo\column
Case 3
*cellinfo\celltype = #egrid_ComboBox
*cellinfo\text = cbString
Case 0, 4
*cellinfo\celltype = #egrid_CheckBox
*cellinfo\text = "TRUE/FALSE"
Case 1
*cellinfo\celltype = #egrid_StaticString
EndSelect
Case #egrid_FormatCell
If Not *cellinfo\row = -1
*cellinfo\forecolour = 8421376
EndIf
If Not *cellinfo\row % 2
*cellinfo\backcolour = 14811135
EndIf
If *cellinfo\row<> - 1 And *cellinfo\row = egrid_SelectedRow(#egrid)
*cellinfo\backcolour = $A5F4F9
EndIf
Default
result = #True
EndSelect
ProcedureReturn result
EndProcedure
column 0 is selectable, i don't know
Posted: Thu Jan 18, 2007 1:11 am
by srod
Does this work:
Code: Select all
Case #egrid_SelectCell
result=1
If *cellinfo\column=0
Select *cellinfo\param ;Informs us how the user attempted to select the cell.
Case #egrid_LeftClick
egrid_MakeCellVisible(#egrid, 0, *cellinfo\row)
result=0 ;Refuse the selection.
Case #egrid_ShiftTab
If *cellinfo\row>0
*cellinfo\row-1
*cellinfo\column=egrid_NumberOfColumns(#egrid)-1
Else
egrid_MakeCellVisible(#egrid, 0, *cellinfo\row)
result=0 ;Refuse the selection.
EndIf
Default
egrid_MakeCellVisible(#egrid, 0, *cellinfo\row)
*cellinfo\column=1
EndSelect
EndIf
RedrawWindow_(GadgetID(#egrid), 0, 0, #RDW_INTERNALPAINT|#RDW_ERASE|#RDW_INVALIDATE)
Posted: Thu Jan 18, 2007 1:16 am
by ts-soft
srod wrote:Does this work:
this works, thanks again
Posted: Thu Jan 18, 2007 1:18 am
by srod
It was simply the fact that you'd placed the 'result = 1' right at the end of the #egrid_SelectCell handler which was cancelling out the custom cell navigation code!

I simply moved this to the beginning.

Posted: Thu Jan 18, 2007 1:23 am
by ts-soft
In german, we say: I did not see the wood before nothing but trees
"Ich sah den Wald vor lauter Bäumen nicht!"
Thanks for your help and thanks again for egrid4
Posted: Thu Jan 18, 2007 1:33 am
by srod
You're welcome. It looks good in your Lib2PBImport application.
Posted: Fri Jan 19, 2007 9:46 pm
by ts-soft
sorry, new problem
If UserResizeColumn, egrid looses the selection
Thomas