Notes on Scrolling

Jun 3, 2009 at 3:05 PM

I have encountered some scrolling quirks.

I have a SourceGrid inside of a panel. The information I'm trying to display has a good amount of columns and some of the columns can get quite wide.

The first problem I encountered was the horizontal scroll bar not showing up initially after after calling AutoSizeCells(), this was awkward because the scroll bar would show up if I resized the window. When I switched to Columns.AutoSize(true), the scroll bar would show up initially just fine.

Another problem I encountered is that one of my columns is wider than the panel that the grid sits inside. This is a problem because SourceGrid seems to only support column scrolling, and the information in that column gets cut off.

I decided to solve the problem by resizing the overall control and using panel scrolling instead. Here is the code:

int width = 4;
int height = 4;

for (int i = 0; i < topGrid.ColumnsCount; i++)
{
width += topGrid.Columns.GetWidth(i);
}

for (int i = 0; i < topGrid.RowsCount; i++)
{
height += topGrid.Rows.GetHeight(i);
}

topGrid.Width = width;
topGrid.Height = height;

I also had to undock the SourceGrid control from the panel so that it would actually resize. The width and height start at 4 after trial and error testing. If they start off lower than that, the scroll bars stay visible on the SourceGrid control, my guess is due to it actually taking up a bit more space than merely the total of the column widths and row heights.

I was wondering if anyone would comment on the solution, is there a better way to go about this?

Jun 3, 2009 at 8:02 PM

The best solution would be to implement pixel scrolling for grid itself but otherwise it's really hard to do something about this as otherwise you have to resize grid itself when user changes column width etc.

Coordinator
Jun 4, 2009 at 12:46 PM

Yes, pixel scorlling would be best. There are plans to implement this, however, not sure how soon it will be done.

Jun 4, 2009 at 3:50 PM

Please consider that if you switch to pixel scrolling you leave in support for cell scrolling as for my application, I prefer row/column scrolling .....

Jun 4, 2009 at 7:54 PM

I think that when such feature will be implemented row/column scrolling will stay default and pixel scrolling will be an option (hopefully that it could be switched diferently for vertical and horizontal scrollbar)

Coordinator
Jun 8, 2009 at 5:46 AM

Yes. it would be best to preserve both column / pixel scrolling, and allow to chose arbitrarily where to enable pixel scrolling - only on rows, or only on columns, or both