<?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>ganshani.com &#187; Datagrid</title>
	<atom:link href="http://www.ganshani.com/tag/datagrid/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ganshani.com</link>
	<description>Puneet Ghanshani - .NET, Silverlight, Sharepoint Articles, Blogs, Poems, Photograph</description>
	<lastBuildDate>Sat, 24 Apr 2010 10:17:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Printing in Silverlight 4</title>
		<link>http://www.ganshani.com/2010/01/11/printing-in-silverlight-4/</link>
		<comments>http://www.ganshani.com/2010/01/11/printing-in-silverlight-4/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 05:46:30 +0000</pubDate>
		<dc:creator>Punit Ganshani</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Datagrid]]></category>
		<category><![CDATA[printing]]></category>

		<guid isPermaLink="false">http://www.ganshani.com/?p=476</guid>
		<description><![CDATA[
			
				
			
		
Another cool feature that Microsoft has included in Silverlight 4 is the ability to Print any UI Element to any printer and that too, without any complicated code. Let&#8217;s have a quick look at implementing this.
Printing starts with the PrintDocument class.  This class exposes several events &#8211; we shall use only one at this moment [...]


<h2>Related posts:</h2><ul><li><a href='http://www.ganshani.com/2009/09/03/controlstoryboardaction-in-silverlight-3/' rel='bookmark' title='Permanent Link: ControlStoryboardAction in Silverlight 3'>ControlStoryboardAction in Silverlight 3</a></li>
<li><a href='http://www.ganshani.com/2009/07/09/silverlight-2-best-practices-i/' rel='bookmark' title='Permanent Link: Silverlight 2 &#8211; Best Practices &#8211; I'>Silverlight 2 &#8211; Best Practices &#8211; I</a></li>
<li><a href='http://www.ganshani.com/2009/07/13/silverlight-2-best-practices-iv/' rel='bookmark' title='Permanent Link: Silverlight 2 Best Practices &#8211; IV'>Silverlight 2 Best Practices &#8211; IV</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.ganshani.com%2F2010%2F01%2F11%2Fprinting-in-silverlight-4%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.ganshani.com%2F2010%2F01%2F11%2Fprinting-in-silverlight-4%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Another cool feature that Microsoft has included in Silverlight 4 is the ability to Print <strong><span style="text-decoration: underline;">any</span></strong> UI Element to <strong><span style="text-decoration: underline;">any</span></strong> printer and that too, without any complicated code. Let&#8217;s have a quick look at implementing this.</p>
<p>Printing starts with the <strong><span style="color: #0000ff;">PrintDocument </span></strong>class.  This class exposes several events &#8211; we shall use only one at this moment &#8211; that are used to call back to ask you about how to print individual pages.</p>
<p>Initial code:</p>
<pre class="brush: csharp">

PrintDocument docDataGrid = new PrintDocument();
docDataGrid.DocumentName = &quot;Data Grid Print using Silverlight 4&quot;;
docDataGrid.PrintPage += new EventHandler&lt;PrintPageEventArgs&gt;(docDataGrid_PrintPage);
docDataGrid.Print();
</pre>
<p>We first defined a friendly DocumentName. This DocumentName is displayed in the Printer Spooler when printing starts. PrintPage is the core function that is invoked when page is printed, so formating and assigning of content should be done in this function.</p>
<pre class="brush: csharp">

void docDataGrid_PrintPage(object sender, PrintPageEventArgs e)
{

// Stretch to the size of the printed page

dataGrid1.Width = e.PrintableArea.Width;

dataGrid1.Height = e.PrintableArea.Height;

// Assign the XAML element to be printed

e.PageVisual = dataGrid1;

// Specify whether to call again for another page

e.HasMorePages = false;

}
</pre>
<p>What&#8217;s happening here? Initially we are resizing the control to be printed (here dataGrid1) to the size of PrintableArea.  This ensures that the page does not remain blank.</p>
<p>Then, we assign the PageVisual property to the element that needs to be printed.  If this is skipped, no content will be printed.</p>
<p>HasMorePages flag indicates whether there are set of trailing pages that need to be printed as well.  If this is set to true, the same method (docDataGrid_PrintPage) will be invoked again.</p>


<p><h2>Related posts:</h2><ul><li><a href='http://www.ganshani.com/2009/09/03/controlstoryboardaction-in-silverlight-3/' rel='bookmark' title='Permanent Link: ControlStoryboardAction in Silverlight 3'>ControlStoryboardAction in Silverlight 3</a></li>
<li><a href='http://www.ganshani.com/2009/07/09/silverlight-2-best-practices-i/' rel='bookmark' title='Permanent Link: Silverlight 2 &#8211; Best Practices &#8211; I'>Silverlight 2 &#8211; Best Practices &#8211; I</a></li>
<li><a href='http://www.ganshani.com/2009/07/13/silverlight-2-best-practices-iv/' rel='bookmark' title='Permanent Link: Silverlight 2 Best Practices &#8211; IV'>Silverlight 2 Best Practices &#8211; IV</a></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.ganshani.com/2010/01/11/printing-in-silverlight-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Datagrid, datalist or repeater</title>
		<link>http://www.ganshani.com/2009/07/24/datagrid-datalist-or-repeater/</link>
		<comments>http://www.ganshani.com/2009/07/24/datagrid-datalist-or-repeater/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 08:56:42 +0000</pubDate>
		<dc:creator>Punit Ganshani</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Microsoft .NET]]></category>
		<category><![CDATA[Datagrid]]></category>
		<category><![CDATA[datalist]]></category>
		<category><![CDATA[repeater]]></category>

		<guid isPermaLink="false">http://www.ganshani.com/?p=245</guid>
		<description><![CDATA[This article describes which is better Datagrid, Datalist or Repeater]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.ganshani.com%2F2009%2F07%2F24%2Fdatagrid-datalist-or-repeater%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.ganshani.com%2F2009%2F07%2F24%2Fdatagrid-datalist-or-repeater%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Developers often make a decision blindly &#8211; they choose a datagrid over datalist and repeater. But that should not be a case.</p>
<p>Datagrid provides ability to allow the end-user to sort, page, and edit its data. But it comes at a <strong><span style="color: #ff0000;">cost of speed</span></strong>. Second the <span style="color: #ff0000;"><strong>display format is simple</strong></span> that is in row and columns.</p>
<p>With its templates, the DataList provides more control over the look and <span style="color: #008000;"><strong>feel of the displayed data </strong></span>than the DataGrid. It offers <span style="color: #008000;"><strong>better performance</strong></span> than datagrid</p>
<p>Repeater control allows for complete and total control. With the Repeater, the only HTML emitted are the values of the databinding statements in the templates along with the HTML markup specified in the templates—<span style="color: #008000;"><strong>no &#8220;extra&#8221; HTML is emitted</strong></span>, as with the DataGrid and DataList. By requiring the developer to specify the complete generated HTML markup, the <span style="color: #ff0000;"><strong>Repeater often requires the longest development time</strong></span>. But repeater does not provide editing features like datagrid so everything has to be coded by programmer.</p>
<p>Summarizing:-</p>
<p>Repeater does boast the best performance of the three data Web controls. Repeater is fastest followed by Datalist and finally datagrid.  Use of Repeater should be prefered over DataGrid and DataList!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ganshani.com/2009/07/24/datagrid-datalist-or-repeater/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
