<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dapfor.Net Grid Blog &#187; grid</title>
	<atom:link href="http://www.blog.dapfor.com/tag/grid/feed" rel="self" type="application/rss+xml" />
	<link>http://www.blog.dapfor.com</link>
	<description>.Net Grid and MFC Grid</description>
	<lastBuildDate>Fri, 09 Sep 2016 05:40:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>.NetGrid v2.9.3 has been released.</title>
		<link>http://www.blog.dapfor.com/netgrid-v2-9-3-has-been-released</link>
		<comments>http://www.blog.dapfor.com/netgrid-v2-9-3-has-been-released#comments</comments>
		<pubDate>Wed, 16 Oct 2013 20:38:04 +0000</pubDate>
		<dc:creator>dapadm</dc:creator>
				<category><![CDATA[bug fixing]]></category>
		<category><![CDATA[new release]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[bugfix]]></category>
		<category><![CDATA[grid]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://www.blog.dapfor.com/?p=232</guid>
		<description><![CDATA[A new grid version containing mostly error fixes and performance improvements has been released. The following improvements have been made: [NEW] Significantly improved cell painting performance. Fixed an error with the grid re-painting the entire row on a notification from a field for which the column is hidden or non-existent. [NEW] Improved the Grid’s disposal [...]]]></description>
			<content:encoded><![CDATA[<p>A new grid version containing mostly error fixes and performance improvements has been released.</p>
<p>The following improvements have been made:</p>
<ul>
<li>[NEW] Significantly improved cell painting performance. Fixed an error with the grid re-painting the entire row on a notification from a field for which the column is hidden or non-existent.</li>
<li>[NEW] Improved the Grid’s disposal algorithm. Handling of the situation when a grid can be disposed in the main thread and receive notifications from a non-GUI thread at the same time has been fixed as compared to the previous version.</li>
</ul>
<p>The following bugs have been fixed:</p>
<ul>
<li>[BUG] Fixed an error when a grid smaller than 20 pixels sometimes could generate exceptions on cell painting.</li>
<li>[BUG] Fixed rendering error when paining merged columns in RTL modе.</li>
<li>[BUG] Fixed header painting error with freezed columns in RTL mode.</li>
<li>[BUG] Fixed an error when moved rows stopped receiving notifications from data source when a grid unsubscribed a row from a datasource with drag&amp;drop operations.</li>
<li>[BUG] Fixed a <a href="http://doc.dapfor.com/net-suite/html/T_Dapfor_Net_Editors_CheckBoxEditor.htm">CheckBoxEditor</a> error when the grid could generate exceptions on partial editor visibility.</li>
</ul>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.dapfor.com/netgrid-v2-9-3-has-been-released/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.NetGrid v2.9.1 has been released.</title>
		<link>http://www.blog.dapfor.com/netgrid-v2-9-1-has-been-released</link>
		<comments>http://www.blog.dapfor.com/netgrid-v2-9-1-has-been-released#comments</comments>
		<pubDate>Wed, 12 Jun 2013 20:31:45 +0000</pubDate>
		<dc:creator>dapadm</dc:creator>
				<category><![CDATA[bug fixing]]></category>
		<category><![CDATA[grid]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://www.blog.dapfor.com/?p=221</guid>
		<description><![CDATA[Fixed an error where the grid does not correctly deserialize columns without filters from xml file.]]></description>
			<content:encoded><![CDATA[<p>Fixed an error where the grid does not correctly deserialize columns without filters from xml file.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.dapfor.com/netgrid-v2-9-1-has-been-released/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.Net performance. Practical recommendations</title>
		<link>http://www.blog.dapfor.com/net-performance-practical-recommendations</link>
		<comments>http://www.blog.dapfor.com/net-performance-practical-recommendations#comments</comments>
		<pubDate>Tue, 15 May 2012 21:07:42 +0000</pubDate>
		<dc:creator>dapadm</dc:creator>
				<category><![CDATA[Performance]]></category>
		<category><![CDATA[grid]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.blog.dapfor.com/?p=167</guid>
		<description><![CDATA[Even the best performing component can be hindered by incorrect use. Below we provide practical recommendations on what should be used or avoided in application programming. Following the tips below you will be able to create applications with the same efficiency as this demo application. We also provide source codes for this example to show [...]]]></description>
			<content:encoded><![CDATA[<div style="text-align: center; margin-bottom: 30px;"><img src="http://www.dapfor.com/images/ProductPicsImages/Performance.jpg" alt="" align="middle" /></div>
<p>Even the best performing component can be hindered by incorrect use. Below we provide practical recommendations on what should be used or avoided in application programming. Following the tips below you will be able to create applications with the same<br />
efficiency as <a href="http://www.dapfor.com/downloads/net-suite-examples/Dapfor.Grid.PerfDemo.zip" target="_blank">this demo application</a>. We also provide <a href="http://www.dapfor.com/downloads/net-suite-examples/Dapfor.Grid.PerfDemo_src.zip" target="_blank">source codes</a> for this example to show how easy it is.</p>
<ul>
<li>It is supposed that programmers already know general principles of application design. Nevertheless, we shall provide  some useful links for better understanding of .Net environment and tools for writing managed code: <a href="http://msdn.microsoft.com/en-us/library/ms973852" target="_blank">Writing Faster Managed Code: Know What Things Cost</a></li>
<li>It is necessary to pay attention to <a href="http://www.dapfor.com/en/net-suite/net-grid/features/performance">grid characteristics</a> in different working modes, to evaluate data volume to be  displayed and to find a relevant chart for better understanding of grid use.</li>
<li>Use ThreadSafeBindingList&lt;T&gt; instead of BindingList&lt;T&gt; for the following reasons:1. BindingList&lt;T&gt; has poor implementation when working with objects that implement INotifyPropertyChanged interface.  <a href="http://www.dapfort.com/en/net-suite/net-grid/tutorial/threadsafe-bindinglist">Here</a>you can find more information on BindingList&lt;T&gt; performance issues.  Use ThreadSafeBindingList&lt;T&gt; instead, as it doesn’t allow BindingList&lt;T&gt; to subscribe to events of objects that it contains.2. Another reason to use ThreadSafeBindingList&lt;T&gt; instead of BindingList&lt;T&gt; is related to implementation of  MulticastDelegate used in events. With one subscriber, this delegate consumes minimum memory resources, but when there are two  or more subscribers, it creates an internal subscriber collection that increases memory consumption dramatically. The grid always subscribes  to objects that implement INotifyPropertyChanged interface and BindingList&lt;T&gt; is the second subscriber.</li>
<li>If BindingList&lt;T&gt; is used together with objects implementing INotifyPropertyChanged interface, it is  better to avoid firing notifications with non-existent data object properties. It is mainly required because when a binding  list receives such notification it checks whether the firing object has the specified property. If the firing object doesn’t  have such property, the BindingList&lt;T&gt; generates <strong>ListChanged</strong> event specifying <strong>Reset</strong> reason and forcing the grid to rebuild all its contents.</li>
<li>Avoid using INotifyPropertyChanged interface, unless it is required. If the object doesn’t change at run-time, it is better not to use this interface to save memory and CPU resources.</li>
<li>Add data to the end of collection (List&lt;T&gt;, BindingList&lt;T&gt;, ThreadSafeBindingList&lt;T&gt; etc). Otherwise, internal implementation of indexed collections will move and re-index all data starting from the newly added index.</li>
<li>Avoid adding data to a binding list with more than 10 000 items when the grid is sorted. Stop sorting to improve performance.  However, if you need to add large amounts of data in real-time to the beginning of the grid, it&#8217;s better to use the following:
<div>
<pre>grid.Sort.Enabled = false;
grid.DataSource = _datasource_;</pre>
<pre>//Add a single object to the beginning of the grid
grid.Nodes.Insert(0, _new_object_);

//Add a single object to the beginning of the binding list
IBindingList bl = ...;
bl.Insert(0, _new_object_);</pre>
</div>
</li>
<li>Although the grid is thread-safe with INotifyPropertyChanged and IBindingList interfaces, use the GUI thread  to work with it. This is mainly important for adding large data volumes. Some optimization algorithms work better when there  is no need to switch between threads. Please also note that BindingList&lt;T&gt; is not thread-safe.</li>
<li>Have only one message loop per application. Don&#8217;t create grids in different threads.Let us assume that the computer resources are not limitless. Theoretically the maximum performance can be obtained  if the number of threads equals to the number of processor cores. While a lot of threads are creating, they aren’t working in parallel.  In this case cores allocate time slices to threads based on their priority and consistently perform context switches (context switch is relatively expansive operation). Note, maximum time slice is about 10-15 msec.We have also take into account that each control paints its content in the GDI/GDI+ device (via the Graphics object).  While painting from one thread all others wait for GDI device to perform painting in its turn. Therefore if we start many  message loops – it doesn’t mean that we accelerate the application. In other words the application losses time on context  switches and on drawing in GDI device.
<p>From our point of view the application should have only one message pump. Windows has additional mechanisms  to optimize content drawing and we are not sure that they work in case of multithreaded environment. Of course,  business logic can work in any thread, but the graphical thread should be only one in the application.</li>
<li>Use MethodInvoker to synchronize threads.In multi-threaded applications every call should be synchronized with the main thread containing windows message loop. Both <strong>Control.Invoke</strong> and <strong>Control.BeginInvoke</strong>methods may accept  different delegate types and their parameters. However, this causes a serious performance issue as they call  Delegate.DynamicInvoke(params object[] args), which in turn uses low-performance reflection. At the same time, for some delegates such as EventHandler, MethodInvoker and WaitCallback the code is called directly.  In the time of code execution the delegate is checked for belonging to one of the above types with specified number of parameters, and if it doesn’t – DynamicInvoke() is called.From practical point of view the synchronization process should look as follows:
<div>
<pre>someControl.BeginInvoke(new MethodInvoker(delegate
{
    //a code here
}));</pre>
</div>
</li>
<li>Use objects of arbitrary classes instead of collections of values of string[] type, etc. It is more convenient and objects of arbitrary classes consume less memory than string collections.</li>
<li>Don’t format values directly in data objects, i.e. if an object property is to return date, this field should return DateTime object type instead of string type. Use <a href="http://www.dapfort.com/en/net-suite/net-grid/tutorial/data-formatting">data formatting</a> if needed. If properties return strings, they can be <a href="http://www.dapfort.com/en/net-suite/net-grid/tutorial/data-sorting">compared incorrectly</a>during data sorting. Besides, comparing two strings requires more CPU resources than comparing two DateTime objects.
<div>
<pre>class DateExample
{
    ...

    //Bad idea
    public string FormattedDate
    {
        get { return string.Format("{0:yyyy-MM-dd}", _date); }
    }

    //Good idea: the property should return non-formatted value
    [Format("yyyy-MM-dd")]
    public DateTime Date
    {
        get { return _date; }
    }
}</pre>
</div>
</li>
<li>Use the <a href="http://www.dapfort.com/en/net-suite/net-grid/tutorial/event-driven-model">event-driven model</a>, if possible. On global scale it is more efficient than searching for rows in one or more grids with dynamically changing data.</li>
<li>Share the same business objects in different grids.  Use <a href="http://www.dapfort.com/en/net-suite/net-grid/tutorial/data-binding">declarative binding</a>. This simplifies the application code and significantly reduces memory consumption.</li>
<li>Avoid using unnecessary wrappers. Use declarative binding instead of <a href="http://www.dapfor.com/en/net-suite/net-grid/features/composite-objects">creating intermediate classes</a>.</li>
<li>Use statically declared EventArgs for data fields to avoid creating numerous short-lived objects when sending notifications via INotifyPropertyChanged interface.
<div>
<pre>class MyDataObject : INotifyPropertyChanged
{
    private static readonly PropertyChangedEventArgs Value1Args = new PropertyChangedEventArgs("Value1");

    private string _value1;

    public string Value1
    {
        get { return _value1; }
        set
        {
            if (_value1 != value)
            {
                _value1 = value;

                //Bad idea: short-lived object is created
                FirePropertyChanged("Value1");

                //Good idea: notify with an immutable static object
                FirePropertyChanged(Value1Args);
            }
        }
    }

    private void FirePropertyChanged(string fieldName)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(fieldName));
        }
    }

    private void FirePropertyChanged(PropertyChangedEventArgs args)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, args);
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;
}</pre>
</div>
</li>
<li>Work with business logic objects directly instead of calling Cell.Value/Row.DataAccessor["fieldId"].ValueTypeDescriptor/PropertyDescriptor are used to display values in cells when working with arbitrary data types.<br />
The following code demonstrates value extraction from data objects.</p>
<div>
<pre>MyDataObject dataObject = ...;
dataObject.Value1 = "some value";

PropertyDescriptor property = TypeDescriptor.GetProperties(dataObject)["Value1"];
object value = property.GetValue(dataObject);</pre>
</div>
<p>This working principle is the same for all grids of all vendors. The main issue is that PropertyDescriptor.GetValue() method uses reflection. NetGrid has an optimization that enables it to receive notifications from INotifyPropertyChanged/IBindingList without calling data object getters. Values are required only at the time of painting and only for visible cells. If the grid has a lot of rows, most of them are invisible and this approach significantly saves CPU resources. It is worth considering in application development. As an example, let’s review subscription to Grid.RowUpdated event:</p>
<div>
<pre>grid.RowUpdated += delegate(object sender, GridRowUpdateEventArgs e)
{
    //This callback is called each time when a notification from INotifyPropertyChanged received.

    //Using of custom object will reduce CPU consumption
    MyDataObject myObject = (MyDataObject) e.Row.DataObject;
    decimal lastPrice = myObject.LastPrice;

    //The following call will use the reflection. Try to avoid.
    lastPrice = (decimal) e.DataField.Value;
};</pre>
</div>
</li>
<li>Use new Row.IsInVisibleBounds property added to version 2.8.0.When updating data in real time in applications, the grid stores highlighting information for each updated cell. This default behavior causes serious consumption of memory resources in addition to CPU resource consumption  due to processing large volume of information. As most updates can occur outside the visible area, the programmer can save CPU resources by using the new property.
<div>
<pre>//Disable authomatic highlighting (from INotifyPropertyChnaged interface)
grid.Highlighting.Enabled = false;

//This callback is called each time when a notification from INotifyProeprtyChanged received.
grid.RowUpdated += delegate(object sender, GridRowUpdateEventArgs e)
{
    //Handle updates only for visible rows
    if(e.Row.IsInVisibleBounds)
    {
        //Using of custom object will reduce CPU consumption
        MyDataObject myObject = (MyDataObject)e.Row.DataObject;
        double delta = myObject.LastPrice - myObject.PrevPrice;
        if(delta != 0)
        {
            Color color = delta &gt; 0 ? Color.Green : Color.Red;
            //highlight the 'LastPrice' cell with specified semi-transparent color for 2 seconds
            e.Row["LastPrice"].Highlight(TimeSpan.FromSeconds(2), Color.FromArgb(50, color));
        }
    }
};</pre>
</div>
<p>When this optimization is used, vertical scrolling may bring rows without cell highlighting information to the visible area and the user will not see cell highlights that were made before rows get to visible area of the grid. This concerns only highlighting information, while text and other cell content will display correctly. The programmer should decide whether to use such optimization or not.</li>
<li>While construction of the hierarchy is preferable to collapse root rows:
<div>
<pre>grid.RowAdded += delegate(object sender, GridRowEventArgs e)
{
    e.Row.Expanded = false;
};</pre>
</div>
</li>
<li>Turn off fading effect when building real-time applications:
<div>
<pre>grid.Highlighting.Fading = false;</pre>
</div>
</li>
<li>Avoid settins colors, fonts in rows and cells because of high memory consumption (Colors and fonts are stored per cell or row). Use <strong>Grid.Appearance / Header.Appearence</strong> properties  and <strong>Grid.PaintRow / Grid.PaintCell</strong>event handlers instead:
<div>
<pre>//The back color is stored per cell. If grid has thousands rows, memory consumption can be very high.
Cell cell = grid.Rows[0]["Price"];
cell.Appearance.BackColor = Color.Red;

//The back color is stored per row. If grid has thousands rows, memory consumption can be very high.
Row row = grid.Rows[0];
row.Appearance.BackColor = Color.Blue;

//Good idea: colors are stored per grid
grid.Appearance.EvenRows.BackColor = Color.FromArgb(10, Color.Red);
grid.Appearance.OddRows.BackColor = Color.FromArgb(10, Color.Blue);

//Good idea: colors are stored per header (therefore per hierarchical level)
Header header = grid.Headers[0];
header.Appearance.EvenRows.BackColor = Color.FromArgb(10, Color.Red);
header.Appearance.OddRows.BackColor = Color.FromArgb(10, Color.Blue);

//Good idea: colors are specified only at painting time
grid.PaintRow += delegate(object sender, PaintRowEventArgs e)
{
    e.Appearance.BackColor = e.Row.VisibleIndex % 2 == 0
                                 ? Color.FromArgb(10, Color.Red)
                                 : Color.FromArgb(10, Color.Blue);
};</pre>
</div>
</li>
<li>Try avoiding reflection.</li>
<li>Be very careful about creating temporary objects as it may result in memory pressure and make garbage  collector collect unused objects more frequently. Please note that when garbage is collected, all application threads  are temporarily stopped.</li>
<li>Don’t use finalizers in objects unless necessary.</li>
</ul>
<p>We hope that these simple recommendations will help you create efficient and high-performing applications.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.dapfor.com/net-performance-practical-recommendations/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.NetGrid v2.8.0 has been released. RTL support, performance improvements</title>
		<link>http://www.blog.dapfor.com/netgrid-v2-8-0-has-been-released-rtl-support-performance-improvements</link>
		<comments>http://www.blog.dapfor.com/netgrid-v2-8-0-has-been-released-rtl-support-performance-improvements#comments</comments>
		<pubDate>Mon, 14 May 2012 21:21:54 +0000</pubDate>
		<dc:creator>dapadm</dc:creator>
				<category><![CDATA[new release]]></category>
		<category><![CDATA[grid]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[release]]></category>
		<category><![CDATA[RTL]]></category>

		<guid isPermaLink="false">http://www.blog.dapfor.com/?p=160</guid>
		<description><![CDATA[We are happy to announce that a new grid version is out. The version 2.8.0 of .Net Grid has a lot of new performance improvements and new features. Performance improvements Significantly improved BindingList performance, especially with objects implementing INotifyPropertyChanged interface. Here you may learn about causes of poor performance and methods for performance improvement. Significantly [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>We are happy to announce that a new grid version is out. The version 2.8.0 of .Net Grid has a lot of new performance improvements and new features.</p>
<h3>Performance improvements</h3>
<ul>
<li>Significantly improved BindingList performance, especially with objects implementing INotifyPropertyChanged interface. <a href="http://www.dapfor.com/en/net-suite/net-grid/tutorial/threadsafe-bindinglist">Here </a>you may learn about causes of poor performance and methods for performance improvement.</li>
</ul>
<ul>
<li>Significantly improved disposing performance for grids with a large number of sorted cells.</li>
</ul>
<ul>
<li>Optimized real-time cell highlighting.</li>
</ul>
<ul>
<li>Added new tutorials with <a href="http://www.dapfor.com/en/net-suite/net-grid/tutorial/performance-practical-recommendations">practical guidelines</a> on grid usage. The <a href="http://www.dapfor.com/downloads/net-suite-examples/Dapfor.Grid.PerfDemo.zip">provided example</a> shows impressive performance that can be achieved by following these simple guidelines.</li>
<li>Significantly increased binding speed of sorted grid</li>
</ul>
<h3>New features</h3>
<ul>
<li>RTL support (in the grid, editors, context menus, tooltips, reporting).</li>
<li>Added support of merged columns for combining columns in groups with common header. Within these groups users may move columns, change column size and run sorting. Full customization of header appearance is supported including insertion of images, changing background color or fonts.
<div><img src="http://support.dapfor.com/attachments/token/sk4443qybxf2dxp/?name=merged_columns.png" alt="merged_columns.png" /></div>
</li>
<li>Added <strong>Grid.Nodes.Insert()</strong> method enabling inserting data, not only at the end of the grid, but also in any position.</li>
<li>Added <strong>Row.Insert()</strong> method enabling inserting data at any hierarchical level in any position.</li>
<li>Foreground color blinking: <strong>Cell.Highlight(TimeSpan interval, Color backColor, Color foreColor)</strong> method was added.</li>
<li>Public toolstrip items <strong>ToolStripGridColumn</strong>, <strong>ToolStripGridGroupBoxPanel</strong>, <strong>ToolStripGridHeaderConfigurator</strong> and <strong>ToolStripGridRemoveSort</strong> were added. Now a programmer can subscribe to <strong>Grid.HeaderContextMenu.ItemClicked</strong> event and get information of header and column where the click was made.</li>
<li>Drag&amp;drop support in grouped rows</li>
<li>Added AllowNew, AllowRemove, AllowEdit setters in <strong>ThreadSafeBindingList&lt;T&gt;</strong></li>
<li>Possibility of using <strong>IFormat</strong> objects in unbound columns was added.</li>
<li>Removing highlighting of entire row upon receiving notification from <strong>INotifyPropertyChanged</strong> with non-existent field.</li>
<li>Support of themes in column filters</li>
<li>Many other improvements (see full list <a href="http://www.dapfor.com/en/net-suite/net-grid/release-notes">here</a>).</li>
</ul>
<p>&nbsp;</p>
<p>Dapfor’s developers continuously strive to improve .NetGrid performance and to add new grid features making it easier for developers to use and greatly increasing performance of grid-based applications. A convenient API makes cell highlighting and simultaneous data filtering, sorting and grouping with highest performance really trivial tasks. Any hierarchy can be created easily. Dapfor is the only grid vendor enabling use of <a href="http://www.dapfor.com/en/net-suite/net-grid/tutorial/event-driven-model">thread-safe event driven model</a> in the application.</p>
<p>We hope that you will appreciate grid quality, performance and convenience of interface. Let’s create feature-rich high-performance applications together.</p>
<p>&nbsp;</p>
<p>Sincererly Yours,</p>
<p>Dapfor</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.dapfor.com/netgrid-v2-8-0-has-been-released-rtl-support-performance-improvements/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
