XBrowse: how to keep the selected row position

Post Reply
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

XBrowse: how to keep the selected row position

Post by Enrico Maria Giordano »

In this sample, try to press the down arrow and then ESC. The new dialog doesn't keep the position of the selected row but moves it to the top.

Is there a way to keep the selected row position?

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    USE CUSTOMER

    TEST()

    TEST()

    RETURN NIL


STATIC FUNCTION TEST()

    LOCAL oDlg, oBrw

    DEFINE DIALOG oDlg;
           SIZE 800, 600

    @ 0, 0 XBROWSE oBrw

    oBrw:CreateFromCode()

    ACTIVATE DIALOG oDlg;
             ON INIT oDlg:SetControl( oBrw );
             CENTER

    RETURN NIL
EMG
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: XBrowse: how to keep the selected row position

Post by cnavarro »

Try with this

Code: Select all

#include "Fivewin.ch"

Static nRowPos := 1

FUNCTION MAIN()

    USE CUSTOMER

    TEST()

    TEST()

    RETURN NIL


STATIC FUNCTION TEST()

    LOCAL oDlg, oBrw

    DEFINE DIALOG oDlg;
           SIZE 800, 600

    @ 0, 0 XBROWSE oBrw

    oBrw:CreateFromCode()
    oBrw:Keyno( nRowPos )

    ACTIVATE DIALOG oDlg;
             ON INIT oDlg:SetControl( oBrw );
             CENTER
    nRowPos  := oBrw:KeyNo

    RETURN NIL

 
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: XBrowse: how to keep the selected row position

Post by Enrico Maria Giordano »

Thank you Cristobal, unfortunately your sample works exactly like mine. Did you try it? Am I missing something?

EMG
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: XBrowse: how to keep the selected row position

Post by cnavarro »

Try with this code, or use METHODS SaveState/RestoreState

Code: Select all


Static nRowPos := 1
Static nRowSel := 1

FUNCTION MAIN()

    USE CUSTOMER

    TEST()

    TEST()

    RETURN NIL


STATIC FUNCTION TEST()

    LOCAL oDlg, oBrw

    DEFINE DIALOG oDlg;
           SIZE 800, 600

    @ 0, 0 XBROWSE oBrw

    oBrw:CreateFromCode()
    oBrw:Keyno( nRowPos )
    oBrw:nRowSel := nRowSel
    oBrw:Refresh()


    ACTIVATE DIALOG oDlg;
             ON INIT oDlg:SetControl( oBrw );
             CENTER
    nRowPos  := oBrw:KeyNo
    nRowSel  := oBrw:nRowSel

    RETURN NIL

 
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: XBrowse: how to keep the selected row position

Post by Enrico Maria Giordano »

Simplified code:

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    USE CUSTOMER

    TEST()

    TEST()

    RETURN NIL


STATIC FUNCTION TEST()

    LOCAL oDlg, oBrw

    STATIC nRowSel := 1

    DEFINE DIALOG oDlg;
           SIZE 800, 600

    @ 0, 0 XBROWSE oBrw

    oBrw:CreateFromCode()

    oBrw:nRowSel = nRowSel

    ACTIVATE DIALOG oDlg;
             ON INIT oDlg:SetControl( oBrw );
             CENTER

    nRowSel = oBrw:nRowSel

    RETURN NIL
EMG
Post Reply