Hello,
I'm using an UltraGrid to display information in an Excel format. The column headers are dates that go for a couple months ahead. Since there are so many dates, you have to use the WinGrid's scrollbar to scroll and see them all.
I am wondering how I can programmatically force a certain cell to be the start of what is showing on the screen. (For example, I have a calendar control, you select a date, and it automatically scrolls the WinGrid so the date you selected is the first visible column in the list.
I've been reading for a while and haven't located anything. Any help will be appreciated!
Thanks!
There is a ScrollCellIntoView on both the RowScrollRegion and ColScrollRegions of the grid that you can use. You could do something like:
this.ultraGrid1.ActiveRowScrollRegion.ScrollCellIntoView(cell, this.ultraGrid1.ActiveColScrollRegion);
-Matt
That is awesome! That works perfectly, thank you so much!
One more question now arises, is there a way to make it so when scrolling it will scroll an entire column at a time? I just implemented your suggestion, and it scrolls the cell into view, but depending on where you were in your scrolling, the cell may be cut off some. (for instance, instead of seeing "05/10/09" in full view, you'll see half of the 0 and then 5/10/09. If I could make it so it forces you when you scroll to make the entire column fit in view, that'd be awesome!
Again thanks a lot for the response I've been pulling out my hair!
You could try using the ScrollColIntoView method instead of the ScrollCellIntoView and pass in 'true' for the 'leftAlign' parameter for the method.
Hi Matt, on my windows form I have two tab. both tab have different different UltraGrid and no link in between. for one grid I am using ScrollColIntoView to set the scroll view for one column. I want that column to align left in scroll region. but its not working when I am passing true for leftalign parameter grid scroll region going mad and it showing scroll from very first column of grid and for false its working some how column is showing in scroll region but in middle. any idea what is happening and why leftalign true is not working?
Hi,
Is the grid visible at the time you are calling ScrollColIntoView? In what event are you calling the method?
Something in your application must be interfering or trying to scroll at the same time you are calling ScrollColIntoView, but I can't really guess what this is, since I don't know anything about your application. The fact that the grid is in a tab control shouldn't make any difference, unless maybe the tab is not currently active and so the grid is not visible.
Hi Mike,
Yes that was the problem, I was calling on InitializeLayout. once I moved the calling function from InitializeLayout to after binding the gird. its works. Thanks a ton.
I think we got the problem. You raised a valid point. I am calling on InitilizeLayout event of grid, I feel I need to call it once the grid bind completely. right now I am out of office, I will do it on Monday, I feel we got the issue it is due to grid not yet ready to set scroll column region. I will update on Monday. Thanks Mike for quick reply.