Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
255
Autorefresh with wingrid
posted

Hi, 

I use a wingrid which  auto refreshes every 5 seconds.The problem that I face is when the user scrolls down the grid, suddenly the grid refreshes and moves back up to the top.I want the grid to stay in the same scroll area after refreshing.I set the the first row as active row  after every refresh.

So how to save the current scroll position and load the same back after refresh?Or can anyone suggest a better solution?

Thanks,

Abja

Parents Reply
  • 579
    Offline posted in reply to Mike Saltzman

    I can't avoid refreshing the data, it is a requirement to have fresh data each x seconds.

    When rows are not grouped by it works, when rows are grouped by and it's a datarow as first row it also works. But when rows are grouped by and the firstrow is Grouped By row it doesn't, the grid is displayed with the first row of the grid on top (<> The first row displayed).

     

    The correct row is found (I seperate the description with "(" seperator to be shure that the number of items (datarows) doesn't change the fact that that groupedbyrow is the first one, like this :

    if (FirstRowDescription != string.Empty)
                    {
                        char[] seperators = { '(' };
                        if (row.Description.Split(seperators)[0] == FirstRowDescription.Split(seperators)[0])
                        {
                            ok = true;
                        }
                    }

    The correct row is found and stored:

    if (CheckIfRowIsFirstRow(row, pkValuesFirstRow))
                        {
                            this.DisplayLayout.RowScrollRegions[0].FirstRow = row;
                            FirstRow = row;
                            setFirstRow = true;
                            DoSearch = false;
                        }

    Here this.DisplayLayout.RowScrollRegions[0].FirstRow has the correct row!

    This method is called in the ctlTaskDataGrid.cs that inherits from UltraGrid.

    I added a Property FirstRow in the ctlTaskDataGrid.cs to store the FirstRow and set it later in the forms using the ctlTaskDataGrid control.

    Then in the LoadData Method on the Form using the ctlTaskDataGrid.cs control (named ugvShipmentMovements in this case) I do this:

    Somewhere the ugvShipmentMovements.DisplayLayout.RowScrollRegions[0].FirstRow was reseted and I can't find where or why. But the most strange behaviour is when I force the ugvShipmentMovements.DisplayLayout.RowScrollRegions[0].FirstRow = ugvShipmentMovements.FirsRow (this is the property I made on the ctlTaskGrid.cs) it doesn't do anything at all:

    This is getting very frustrating.. Any help is more than welcome!

    First I thought it had something to do with the inheritance somehow, but then why does it works fine with a datarow? It's the exact same way of setting it, only then ugvShipmentMovements.DisplayLayout.RowScrollRegions[0].FirstRow doesn't get resetted.

     

     

Children