Started by diogenes ·
2016-05-27 19:04 UTC ·
6 replies · SMF topic #2375
diogenes
2016-05-27 19:04 UTC
Hi.
I have a grid (table). I need the behavior is like an excel sheet. When pressing return to finish entering data in a cell, the focus goes to the next cell. It's that possible?
thanks
fred_tomke
2016-06-01 05:06 UTC
Hi, yes it is. Have a search for CancelCellEdit, SetCurCell and StartCellEdit, maybe also AddRow in the forum and in the help. That's all you need.
Regards, Fred
diogenes
2017-08-18 18:17 UTC
Yes i know. But how i can capture the event when i press enter after change the content of the cell?
roy_043
2017-08-20 14:12 UTC
Here is an example that may help.
I was unable to solve two issues:
[list type=decimal]
The SetFocus event of the grid never seems to fire. As a workaround the SelChanged and BeginLabelEdit events are used to determine if the grid has the focus.
The dcl-Grid-StartCellEdit function seems to not work properly inside the OnInitialize event handler of the form. The user can't start typing right away but has to press the Space Bar first.
Test data:
BricsCAD 16.2.15
OpenDCL 8.1.3.1
roy_043
2017-08-21 19:24 UTC
Moving the initial call to dcl-Grid-StartCellEdit from the OnInitialize event handler to the OnTimer event handler of the form solves issue #2. See attached files.
Does issue #1 perhaps only occur in BricsCAD?
roy_043
2017-08-22 08:37 UTC
Here is a new version using the dcl-GetFocus function. This version relies on fewer event handlers.
Again there seems to be an issue establishing the focus of the grid:
[list type=decimal]
After the focus has been moved to the grid using the Tab key, the Enter key can now be used to 'activate' the cell. In this case dcl-GetFocus returns a correct list: ("GrdTest" "Form" "Grd").
If the Enter key is then used to jump to the next cell dcl-GetFocus returns nil. This seems strange, but the code does make use of this 'feature'.
diogenes
2017-09-12 06:59 UTC
nice solution.
thanks