grid behavior

Started by diogenes, May 27, 2016, 12:04:28 PM

Previous topic - Next topic

diogenes

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

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
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

diogenes

Yes i know. But how i can capture the event when i press enter after change the content of the cell?

roy_043

#3
Here is an example that may help.

I was unable to solve two issues:

  • 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

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

#5
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:

  • 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