Search Results

Search found 1 results on 1 pages for 'user365581'.

Page 1/1 | 1 

  • Problems setting vertical scrollbar value in a datagrid (old one, not the better DataGridView).

    - by user365581
    I need to save the selected row and the vertical scrollBar's position after a refresh. This is how I do it: int currRow = myGrid.CurrentRowIndex; int vScrollPos = ((ScrollBar)myGrid.Controls[1]).Value // some code that refreshes the data among other things myGrid.CurrentRowIndex = currRow; // this sets the property myGrid.Select(currRow); // this selects in UI (both commands required) ((ScrollBar)myGrid.Controls[1]).Value = vScrollPos; Here's my problem: The grid always jumps to a place where the selected row is at the bottom. setting the current row makes it happen - similar to EnsureVisible of newer grid implementations. But after that there's the vScrollBar repositioning - and it just doesn't work right. In debug I see that the scroll bar value gets updated. In the UI, if I hit the down/up arrow on the scrollbar it suddenly jumps to the right place - But if I don't click anything the grid is just in the wrong position. I tried refreshing the grid/scroll bar to force a redraw, but it doesn't help. The actual grid position is just not in sync with the vertical ScrollBar's value. Any ideas?

    Read the article

1