DevExpress XtraGrids horizontal scroll is slow. How to speed it up? - winforms

I have 11 visible grids that are synchronized - LeftCoords of children ones is set when LeftCoord of parent one changes. Those grids have around 50 columns, but it could possibly by more. When all grids are visible horizontal scrolling becomes very slow. Those grid have some customized behaviors.
Is there some grid functionality that makes horizontal scroll slower, or is it normal speed? Are there any known ways of making it faster?
I am using version 13.2.
Thanks,
Peter

You have a lot of columns in grid. I suggest you that you limit the number of columns to show by hiding unnecessary ones. If an end-user needs a particular column, he/she will be able to make it visible from the Column Chooser.
Handling any custom draw events, applying format conditions, or using unbound columns will decrease performance.
Source: Horizontal scrolling is very slow when there are large number of columns in the grid
Please increase the GridView.HorzScrollStep property and set the
GridView.ScrollStyle property to none to disable live scrolling.
Additionally, there is a request on providing the per-column scrolling
in the XtraGrid at Horizontal scrolling by a column at a time (as in
MS Excel)
References:
Scrolling speed both Horizontal an vertical

Related

How to scroll a DevExpress Xtragrid horizontally but by full columns

I want to scroll a grid horizontally. By default, it scrolls pixel by pixel. I want to scroll column by column. Simply, a column should shift to left/right 100% or 0%. Shouldn't scroll by a fraction of it's width. (This applies to the first column visible to the user at the moment).
What I want is a way to do "snappy" scroll.
How can I get this done?
To scroll grid's content, use the GridView.LeftCoord property. To access boundaries of columns, the GridViewInfo.ColumnsInfo collection will be helpful. You can see how to implement this feature in the How to implement scrolling by columns in the grid e2481 example.

Automatic width for display of FlowDocument

In my application, I'm generating a FlowDocument with several paragraphs of text.
Using a FlowDocumentScrollViewer , I can display the document in my UI. If the document is too long for the available space, the FlowDocumentScrollViewer does it's job and introduces a vertical scrollbar. All good.
If I use a FlowDocumentPageViewer the response to show additional pages of text, also as designed.
However, what I want in my application is for the viewer to grow wider.
So, for a short document, the viewer is narrow (say, around 360 pixels with one column of text), but for a longer document the viewer is wider (say, around 720 pixels with two columns of text). An even longer document would expand to three columns, and so on.
I've seen a number of WinRT applications that do this kind of thing - The New Zealand Herald has one app. But, I'm working in regular WPF and have ended up stumped.
How can I display a FlowDocument so that it's all visible at once - no scrollbars, no pagination, just multiple columns of text stretching across?
Why do I want this? I'm showing several disparate pieces of information on a single page, and I want to have a single horizontal scrollbar for panning across the lot, not separate scrollbars for each piece. For example, I've got my ListBoxes working this way by using a WrapPanel as the ItemsPanelTemplate - when there are too many items for one column, another column opens up and the listbox gets wider to accomodate.

WPF DataGrid : CanContentScroll property causing odd behavior

I have a solution where I generate a DataGrid (or multiple instances) based on user criteria. Each grid keeps receiving data as it comes in via an ObservableCollection.
The problem I had was that the scroll acted weird. It was choppy, and scrollbar would resize itself while scrolling.
Then I found the CanContentScroll property! It completely fixes the weird scrolling behavior bringing me temporary bliss and happiness.
However, it causes two unfortunate side effects:
Whenever I re-create DataGrid instances and bind them to my ObservableCollection, it freezes my entire window for 5 seconds. When my DataGrid grows to a big size, this delay can last for 30 seconds.
When I call TradeGrid.ScrollIntoView(TradeGrid.Items(TradeGrid.Items.Count - 1)) to scroll to the bottom, it jumps to bottom and then back to the top.
Is there another way to achieve smooth scrolling perhaps?
You are encountering the differences between physical scrolling and logical scrolling.
As you have discovered, each has its tradeoffs.
Physical scrolling
Physical scrolling (CanContentScroll=false) just goes by pixels, so:
The viewport always represents exactly the same portion of your scroll extent, giving you a smooth scrolling experience, and
but
The entire contents of the DataGrid must have all templates fully applied and be measured and arranged to determine the size of the scrollbar, leading to long delays during loading and high RAM usage, and
It doesn't really scroll items so it doesn't understand ScrollIntoView very well
Logical scrolling
Logical scrolling (CanContentScroll=true) calculates its scroll viewport and extent by items instead of pixels, so:
The viewport may show a different number of items at different times, meaning the number of items in the viewport as compared to the number of items in the extent varies, causing the scrollbar length to change, and
Scrolling moves from one item to the next and never in between, leading to "jerky" scrolling
but
As long as you're using VirtualizingStackPanel under the hood, it only needs to apply templates and measure and arrange the items that are actually visible at the moment, and
ScrollIntoView is much simpler since it just needs to get the right item index into view
Choosing between them
These are the only two kinds of scrolling provided by WPF. You must choose between them based on the above tradeoffs. Generally logical scrolling is best for medium to large datasets, and physical scrolling is best for small ones.
A trick to speed loading during physical scrolling is to make the physical scrolling better is to wrap your items in a custom Decorator that has a fixed size and sets its child's Visibility to Hidden when it is not visible. This prevents the ApplyTemplate, Measure and Arrange from occuring on the descendant controls of that item until you're ready for it to happen.
A trick to make physical scrolling's ScrollIntoView more reliable is to call it twice: Once immediately and once in a dispatcher callback of DispatcherPriority.ApplicationIdle.
Making logical scroll scrollbar more stable
If all your items are the same height, the number of items visible in the viewport at any time will stay the same, causing the scroll thumb size to stay the same (because the ratio with total number if items doesn't change).
It is also possible to modify the behavior of the ScrollBar itself so the thumb is always calculated to be a fixed size. To do this without any hacky code-behind:
Subclass Track to replace the calculation of Thumb position and size in MeasureOverride with your own
Change the ScrollBar template used for the logical-scrolling ScrollBar to use your subclassed Track instead of the regular one
Change the ScrollViewer template to explicitly set your custom ScrollBar template on the logical-scrolling ScrollBar (instead of using the default template)
Change the ListBox template to use explicitly set your custom ScrollViewer template on the ScrollViewer it creates
This means copying a lot of template code fom the built-in WPF templates, so it is not a very elegant solution. But the alternative to this is to use hacky code-behind to wait until all the templates are expanded, then find the ScrollBar and just replace the ScrollBar template with the one that uses your custom Track. This code saves two large templates (ListBox, ScrollViewer) at the cost of some very tricky code.
Using a different Panel would be a much larger amount of work: VirtualizingStackPanel is the only Panel that virtualizes, and only it and StackPanel to logical scrolling. Since you are taking advantage of VirtualizingStackPanel's virtualization abilities you would have to re-implement all of these plus all IScrollInfo info function plus your regular Panel functions. I could do something like that but I would allocate several, perhaps many, days to get it right. I recommend you not try it.
I also have same issue with my DataGrid and finally I did:
ScrollViewer.CanContentScroll="True"
EnableRowVirtualization="True"
VirtualizingPanel.VirtualizationMode="Standard"
Now everything is working fine in my DataGrid.

Possible to Freeze Columns in a WPF ListView/GridView?

I currently have a GridView inside a ListView.View. The GridView columns will far exceed the width of the screen, so there will always be horizontal scrolling.
What I would like to do is to have certain columns always remain on the screen regardless of scrolling. So the first x columns from the left are frozen (ala Excel), and the rest can scroll.
It does not need to be dynamic/user selected--I know in advance which columns need to be frozen.
Is this possible?
Quick and dirty solution would be to use two listviews next to each other. Left one would be for the frozen columns and right one would have horizontal scrolling enabled. If you need vertical scrolling you can wrap both listviews in a scrollviewer.

Why don't my scrollbars work properly when programmatically hiding rows in silverlight Datagrid?

I have a Silverlight datagrid with custom code that allows for +/- buttons on the lefthand side and can display a table with a tree structure. The +/- buttons are bound to a IsExpanded property on my ViewModelRows, as I call them. The visibility of rows is bound to an IsVisible property on the ViewModelRows which is determined based on whether or not all of the parent rows are expanded. Straightforward enough.
This code works fine in that if I scroll up and down the grid with PageUp/PageDown or the arrow keys, all the right rows are hidden and everything has the right structure and I can play with the +/- buttons to my hearts content. However, the vertical scroll bar on the right hand side, although it starts off the correct size and it scrolls through the rows smoothly, when I collapse rows and then re-expand them, doesn't go back to its correct size. The scrollbar can still usually be moved around to scroll through the whole collection, but because it is too big, once the bar moves to the bottom, there are still more rows to go through and it sort of jerkily shoots all the way down to the bottom or sometimes fails to scroll at all. This is pretty hard to describe so I included a screenshot with the black lines drawn on to show the difference in scrollbar length even though the two grids have the same number of rows expanded.
I think this might be a bug related to the way the Datagrid does virtualization of rows. It seems to me like it isn't properly keeping track of how tall each row is supposed to be when expansion states change. Is there a way to programmatically "poke" (read hack) it to recalculate its scrollbar size on LoadingRow or something ugly like that? I'd include a code sample but there's 2 c# files and 1 xaml file so I wanted to see if anyone else has heard of this sort of issue before I try to make it reproducible in a self-contained way. Once again, scrolling with the arrow keys works fine so I'm pretty sure the underlying logic and binding is working, there's just some issue with the row height not being calculated properly.
Since I'm a new user, it won't let me use image tags so here's the link to a picture of the problem:
http://img210.imageshack.us/img210/8760/messedupscrollbars.png
This is a known issue according to what I read today (and is apparently still an issue in the as-yet-unreleased Silverlight 4):
http://forums.silverlight.net/forums/p/153997/343790.aspx

Resources