This sample shows a typical market update simulation and how a Grid Grouping Control handles those high-frequency updates. It also discusses various built-in optimization properties.
Features:
The sample design is explained in the following illustration:
The data table is filled with data objects and bound to the grid.
On the Form_load, a worker thread is invoked (System.Timers) and updates the data objects randomly based on the Symbols fields.
It raises an event with the changed data objects.
The main GUI thread subscribes to this event and synchronizes changes to the bound data table.
The built-in properties the grid provides for high-frequency updates and optimizations are as follows:
GridGroupingControl.BlinkTime-Adds optional support to highlight values in a record for a short time after a change is detected.
The engine will highlight a cell for the specified period in milliseconds if the value is increased or decreased.
GridGroupingControl.UpdateDisplayFrequency-Allows specification of how often the display should be updated when a new ListChanged event-handler logic is used.
This property will have no effect if the UseOldListChangedHandler is set to true.
GridGroupingControl.InvalidateAllWhenListChanged-Lets you specify if the grid should simply call Invalidate when a ListChanged event is handled or if it should determine the area that is affected by the change and call InvalidateRange
It may seem better to determine the affected area by a change and call InvalidateRange, but when calling InvalidateRange, the grid needs to know the exact position of the record in the table before it can mark that area as dirty.
In order to determine the record position (and y-position of the row in the display), counters need to be evaluated. This operation can cost more time than simply calling Invalidate in high-frequency update scenarios.
Also, the group caption bar needs to be updated when a record changes. Check out the TableListChangedEventArgs class for the Syncfusion.Windows.Forms.Grid.Grouping.GridGroupingControl.SourceListListChanged event.
It provides properties to not mark specific counters as dirty. In cases when counters are not marked dirty, InvalidateRange will be much faster. Counters only need to be marked dirty when there is a chance that the sort order is affected, if the filter-hidden state of a record is affected, or if custom counters are used.
GridGroupingControl.UseDefaultsForFasterDrawing-Initializes recommended settings to improve handling of ListChanged events and scrolling through a grid
Affected settings are:
TableOptions.ColumnsMaxLengthStrategy
TableOptions.GridLineBorder
TableOptions.DrawTextWithGdiInterop
TableOptions.VerticalPixelScroll
Appearance.AnyRecordFieldCell.WrapText
Appearance.AnyRecordFieldCell.Trimming
GridGroupingControl.SortPositionChangedBehavior-Specifies grid reaction when sort position of a record changes
GridGroupingControl.InsertRemoveBehavior-Specifies grid reaction when records are inserted or deleted
Enums for SortPositionChangedBehavior and InsertRemoveBehavior
InvalidateAll-Invalidate the display, do not check position of record
InvalidateVisible-Invalidate only the visible portion of a display affected by a change
If the record is above the current view, change the top row to minimize scrolling.
ScrollWithImmediateUpdate-Scroll contents
If the record is above the current view, change the top row to minimize scrolling. Changes are visible immediately.