grid behavior

Started by diogenes · 2016-05-27 19:04 UTC · 6 replies · SMF topic #2375

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
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
Yes i know. But how i can capture the event when i press enter after change the content of the cell?
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
    Attachments
    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?
    Attachments
    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'.

  • Attachments
    nice solution.
    thanks