C1.Win.C1TrueDBGrid.C1TrueDBGrid.DisplayColumns.AllowFocus issue

Posted by: jens.eidinger on 17 January 2021, 9:29 pm EST

    • Post Options:
    • Link

    Posted 17 January 2021, 9:29 pm EST - Updated 3 October 2022, 2:23 pm EST

    Hi,

    my customer used in a VB6 application this control TrueOleDBGrid70.TDBGrid .

    The property AllowFocus for columns works different now to the WinForm version.

    When you set AllowFocus for a column to false in VB6 you still get event RowColChange and also the Row property changed to new row, but in WinForm this does not happen.

    I only get the click event and when trying to change there the Row to the new one, which I got from the CellContaining function, is not working.

    Is there a fix for that? Having columns, which have set AllowFocus to false, and still get RowColChange event and changing Row property when clicking on another row, like in TrueOleDBGrid70.TDBGrid?

    Attached a screen: on the left VB, on the right WinForm. I clicked on some rows. In VB the RowColChange event is send and also the Row property changed. In WinForm I only get the Click event with a wrong Row.

    Best,

    Jens

  • Posted 18 January 2021, 6:36 pm EST

    Hi Jens,

    This behavior is by design since the RowColChange event only fires when the focus moves to a different cell and the Row property only changes when the current cell is changed i.e. the focused cell is changed. Since you have prevented the column from getting focus by setting the AllowFocus to false, the RowColChange event will not fire, and the Row property will not change for that column.

    As a workaround to achieve your requirement, you can set the AllowFocus property of the column to true, then in the RowColChange event, you can check if the new current cell is of that column and if it is then you can change the current cell back to the last current cell using the LastCol and LastRow properties of RowColChangeEventArgs. Please refer to the sample attached.

    If you have any questions, please let me know.

    Note- The ActiveX and WinForms versions of the grid are different architecturally and there might be differences in the behaviors too.

    Thanks.

    TrueDbGrid.zip

  • Posted 11 February 2021, 6:48 pm EST

    Hi Pragati,

    thanks for your reply. Based on your example I could built a Workaround.

    Best,

    Jens

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels