<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>A road through .Net 2.0 +</title>
	<atom:link href="http://ajhorus.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://ajhorus.wordpress.com</link>
	<description>Experiences programming with .net 2.0 and 3.0</description>
	<lastBuildDate>Mon, 27 Oct 2008 17:15:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='ajhorus.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>A road through .Net 2.0 +</title>
		<link>http://ajhorus.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://ajhorus.wordpress.com/osd.xml" title="A road through .Net 2.0 +" />
	<atom:link rel='hub' href='http://ajhorus.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Apply function to LINQ query</title>
		<link>http://ajhorus.wordpress.com/2008/10/24/applying-a-function-to-result-query-object-linq/</link>
		<comments>http://ajhorus.wordpress.com/2008/10/24/applying-a-function-to-result-query-object-linq/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 21:01:24 +0000</pubDate>
		<dc:creator>ajhorus</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ajhorus.wordpress.com/?p=20</guid>
		<description><![CDATA[In my last project i have been working with linq to do some cool stuff with objects. Like manipulating controls and specially doing any sort of filtering. I gotta say, linq is great for this. Many of you have in some point or another use a for each loop to filter the objects based on their properties; well, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajhorus.wordpress.com&amp;blog=1055793&amp;post=20&amp;subd=ajhorus&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In my last project i have been working with linq to do some cool stuff with objects. Like manipulating controls and specially doing any sort of filtering. I gotta say, linq is great for this. Many of you have in some point or another use a for each loop to filter the objects based on their properties; well, this all can be done easier using linq.</p>
<p>Ex. Closing windows using LinQ to object and expressions.  I am filtering all the windows for the current app and at the same time closing them. Calling the Count() function force the linq expression to apply the function and close the window.</p>
<p><span style="color:#339966;">private int closeWin(Window w)<br />
{<br />
 w.Close();<br />
 return 0;<br />
}<br />
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)<br />
{      <br />
 System.Linq.Expressions.Expression&lt;Func&lt;Window, double?&gt;&gt; calc = (w) =&gt; closeWin(w);</span></p>
<p><span style="color:#339966;"> var childWindows = (from w in Application.Current.Windows.OfType&lt;Window&gt;()<br />
      where w.Name != &#8220;mainWin&#8221;<br />
      select calc.Compile().Invoke(w));<br />
 var count = childWindows.Count();<br />
 <br />
}</span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ajhorus.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ajhorus.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ajhorus.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ajhorus.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ajhorus.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ajhorus.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ajhorus.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ajhorus.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ajhorus.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ajhorus.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ajhorus.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ajhorus.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ajhorus.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ajhorus.wordpress.com/20/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajhorus.wordpress.com&amp;blog=1055793&amp;post=20&amp;subd=ajhorus&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ajhorus.wordpress.com/2008/10/24/applying-a-function-to-result-query-object-linq/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d170e8724c0735e4740fe7a730470345?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ajhorus</media:title>
		</media:content>
	</item>
		<item>
		<title>Xceed single click checkbox</title>
		<link>http://ajhorus.wordpress.com/2008/10/24/xceed-single-click-checkbox/</link>
		<comments>http://ajhorus.wordpress.com/2008/10/24/xceed-single-click-checkbox/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 20:50:18 +0000</pubDate>
		<dc:creator>ajhorus</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ajhorus.wordpress.com/?p=21</guid>
		<description><![CDATA[I apologize for not writting sooner,  I was far away from the wpf/silverlight world. Been stuck with a winform project. Thanks God is over. The latest version of Xceed Datagrid has a lot of goodies. One of the is the single click checkbox.  If we are using a DataGridCollectionView as our dataitem, all we need [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajhorus.wordpress.com&amp;blog=1055793&amp;post=21&amp;subd=ajhorus&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I apologize for not writting sooner,  I was far away from the wpf/silverlight world. Been stuck with a winform project. Thanks God is over.</p>
<p>The latest version of Xceed Datagrid has a lot of goodies. One of the is the single click checkbox.  If we are using a DataGridCollectionView as our dataitem, all we need to do to present the checkbox is declare the itemgrid property of type boolean.</p>
<pre><span style="color:#008000;"><strong>&lt;xceed:DataGridCollectionViewSource x:Key="dgGridSource"
                                         Source="{Binding}"&gt;
 &lt;xceed:DataGridCollectionViewSource.ItemProperties&gt;
                &lt;xceed:DataGridItemProperty Name="Name"
    IsReadOnly="True"  ValuePath="Name"    /&gt;
                &lt;xceed:DataGridItemProperty Name="Age"
    IsReadOnly="True" ValuePath="Age"   /&gt;
                &lt;xceed:DataGridItemProperty Name="Male"
    DataType="{x:Type System:Boolean}"
    IsReadOnly="False" ValuePath="IsMale" /&gt;
 &lt;/xceed:DataGridCollectionViewSource.ItemProperties&gt;
&lt;/xceed:DataGridCollectionViewSource&gt;</strong></span></pre>
<p> The importan line here is as the DataType attribute. <span style="color:#008000;"><strong>DataType=&#8221;{x:Type System:Boolean}&#8221;.  </strong><span style="color:#000000;">In<strong> </strong></span></span><span style="color:#000000;">order to have access to the System namespace we need to add this reference to our control.  </span></p>
<p> <span style="color:#000000;">xmlns:System=&#8221;clr-namespace:System;assembly=mscorlib&#8221; </span></p>
<p>Then to get the single click editing we need to set the following attributes to the xceed datagrid. EditTrigger and CellEditorDisplayConditions.</p>
<pre><span style="color:#008000;"><strong>&lt;xceed:DataGridControl    x:Name="dgGrid"
                                ItemsSource="{Binding}"
                              <span style="color:#ffff99;">  </span><span style="color:#ffff99;"><span>EditTriggers="SingleClick"
                                CellEditorDisplayConditions="MouseOverCell"</span>
</span>                               &gt;
&lt;/&lt;xceed:DataGridControl&gt;</strong></span>
<strong><span style="color:#000000;">That's it.  </span></strong></pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ajhorus.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ajhorus.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ajhorus.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ajhorus.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ajhorus.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ajhorus.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ajhorus.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ajhorus.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ajhorus.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ajhorus.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ajhorus.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ajhorus.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ajhorus.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ajhorus.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajhorus.wordpress.com&amp;blog=1055793&amp;post=21&amp;subd=ajhorus&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ajhorus.wordpress.com/2008/10/24/xceed-single-click-checkbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d170e8724c0735e4740fe7a730470345?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ajhorus</media:title>
		</media:content>
	</item>
		<item>
		<title>Transparent WPF Window</title>
		<link>http://ajhorus.wordpress.com/2007/11/29/test-writer/</link>
		<comments>http://ajhorus.wordpress.com/2007/11/29/test-writer/#comments</comments>
		<pubDate>Thu, 29 Nov 2007 04:00:27 +0000</pubDate>
		<dc:creator>ajhorus</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ajhorus.wordpress.com/2007/11/29/test-writer/</guid>
		<description><![CDATA[&#160; For those who have played a bit with the exciting WPF windows, you may have noticed that the transparency of the form is related to the the windowstyle property. In other words, if you want to set the AllowTransparecy property to true, you would have to set the WindowStyle property to none.&#160; One may [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajhorus.wordpress.com&amp;blog=1055793&amp;post=19&amp;subd=ajhorus&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p>For those who have played a bit with the exciting WPF windows, you may have noticed that the transparency of the form is related to the the windowstyle property. In other words, if you want to set the <font color="#ffff00">AllowTransparecy</font> property to true, you would have to set the <font color="#ffff00">WindowStyle</font> property to none.&nbsp; One may wonder why does MS force us to do this,&nbsp; well&nbsp; in short;&nbsp; Not all of the window is drawn by WPF. The title bar and border are still render by GDI+.&nbsp; This means that any transformation or rendering possible on all the other objects in WPF are not possible on these two parts of the window.&nbsp; </p>
<p>Therefore, in order to create a custom transparent window we must get rid of the border drawn by GDI+.&nbsp; We can accomplish this in one line of code, however we must now handle manually the closing, resizing and dragging.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ajhorus.wordpress.com/19/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ajhorus.wordpress.com/19/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ajhorus.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ajhorus.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ajhorus.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ajhorus.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ajhorus.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ajhorus.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ajhorus.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ajhorus.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ajhorus.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ajhorus.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ajhorus.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ajhorus.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ajhorus.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ajhorus.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajhorus.wordpress.com&amp;blog=1055793&amp;post=19&amp;subd=ajhorus&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ajhorus.wordpress.com/2007/11/29/test-writer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d170e8724c0735e4740fe7a730470345?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ajhorus</media:title>
		</media:content>
	</item>
		<item>
		<title>Xceed Datagrid Custom Cell Styling</title>
		<link>http://ajhorus.wordpress.com/2007/11/22/xceed-datagrid-custom-cell-styling/</link>
		<comments>http://ajhorus.wordpress.com/2007/11/22/xceed-datagrid-custom-cell-styling/#comments</comments>
		<pubDate>Thu, 22 Nov 2007 16:57:13 +0000</pubDate>
		<dc:creator>ajhorus</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ajhorus.wordpress.com/2007/11/22/xceed-datagrid-custom-cell-styling/</guid>
		<description><![CDATA[As good as Xceed Datagrid is, it&#8217;s lacking some basic functionality or the documentation to find the workarounds.  We experience this when we tried to custom change the background of individuals cells base on their value.  A colleague of mine was working on this issue during the last week. After some extensive trial and error [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajhorus.wordpress.com&amp;blog=1055793&amp;post=16&amp;subd=ajhorus&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://ajhorus.files.wordpress.com/2007/11/xceed_customcell.jpg" title="xceed_customcell.jpg"></a></p>
<p><a href="http://ajhorus.files.wordpress.com/2007/11/xceed_customcell1.jpg" title="xceed_customcell1.jpg"><img src="http://ajhorus.files.wordpress.com/2007/11/xceed_customcell1.jpg?w=497" alt="xceed_customcell1.jpg" /></a></p>
<p>As good as Xceed Datagrid is, it&#8217;s lacking some basic functionality or the documentation to find the workarounds.  We experience this when we tried to custom change the background of individuals cells base on their value.  A colleague of mine was working on this issue during the last week. After some extensive trial and error he came out with this solution.</p>
<p>Basically we need to register a Xceed.Wpf.DataGridControl.DataRow event,  Any event that gets called for all the DataRows in the DataGrid will suffice.   We decided to use the DataRow.SizeChangedEvent. </p>
<p><code>EventManager.RegisterClassHandler(typeof(Xceed.Wpf.DataGrid.DataRow),<br />
Xceed.Wpf.DataGrid.DataRow.SizeChangedEvent, new RoutedEventHandler(onDataRowSizeChanged));<br />
</code></p>
<p>We register a class handler event. This could be done inside the main constructor of your window. After that we implement the handler method as such:</p>
<p><code><br />
void onDataRowSizeChanged(object sender, RoutedEventArgs e)<br />
{<br />
    Xceed.Wpf.DataGrid.<font color="#0000ff">DataRow</font> dRow = (sender as Xceed.Wpf.DataGrid.<font color="#0000ff">DataRow</font>);<code>    //Getting the data value of the cells wanted:</code><code>    <font color="#0000ff">DataRowView</font> drView = dRow.DataContext as <font color="#0000ff">DataRowView</font>;<br />
    //Do our custom sytling base on data Values<br />
    if (drView["equity"].ToString() == "0")<br />
    {<br />
       dRow.Cells["equity"].Background = Brushes.Red;<br />
    }<br />
    if (drView["balance"].ToString() == "0")<br />
    {<br />
       dRow.Cells["balance"].Background = <font color="#0000ff">Brushes</font>.LightGreen;<br />
    }<br />
    if (drView["longvalue"].ToString() == "2282508")<br />
    {<br />
       dRow.Cells["longvalue"].Background = <font color="#0000ff">Brushes</font>.Green;<br />
       dRow.Cells["longvalue"].Foreground = <font color="#0000ff">Brushes</font>.Blue;<br />
    }</code></code><code><code></code><code><code></code><code><code></code><code>}</code></code></code><code> </code></code><code><code><code><code></code></code>Below is the xmal of the window:</code></code><code><code></code></code><code> </code><code><font size="2" color="#0000ff">&lt;<font size="2" color="#a31515">Window</font><font size="2" color="#ff0000"> x</font><font size="2" color="#0000ff">:</font><font size="2" color="#ff0000">Class</font><font size="2" color="#0000ff">="WPFPeformanceTest.XceedDataGrid"</font></font></code><code><font size="2" color="#0000ff"><font size="2"><font size="2" color="#ff0000">xmlns</font><font size="2" color="#0000ff">="http://schemas.microsoft.com/winfx/2006/xaml/presentation"</font></font></font></code><code><font size="2" color="#0000ff"><font size="2"><font size="2" color="#ff0000">xmlns</font><font size="2" color="#0000ff">:</font><font size="2" color="#ff0000">x</font><font size="2" color="#0000ff">="http://schemas.microsoft.com/winfx/2006/xaml"</font></font><font size="2"><font size="2"><font size="2" color="#ff0000">xmlns</font><font size="2" color="#0000ff">:</font><font size="2" color="#ff0000">xcdg</font><font size="2" color="#0000ff">="http://schemas.xceed.com/wpf/xaml/datagrid"</font></font></font></font></code><code><font size="2" color="#0000ff"><font size="2"><font size="2" color="#ff0000">xmlns</font><font size="2" color="#0000ff">:</font><font size="2" color="#ff0000">xauto</font><font size="2" color="#0000ff">="clr-namespace:HelperClasses;assembly=HelperClasses"</font></font><font size="2"><font size="2"><font size="2" color="#ff0000">Title</font><font size="2" color="#0000ff">="Xceed DataGrid Custom Cell Style"</font><font size="2" color="#ff0000"> Height</font><font size="2" color="#0000ff">="250"</font><font size="2" color="#ff0000"> Width</font><font size="2" color="#0000ff">="800"</font></font></font><font size="2"><font size="2"><font size="2" color="#ff0000">WindowStyle</font><font size="2" color="#0000ff">="ThreeDBorderWindow"&gt;</font></font><font size="2"><font size="2" color="#a31515"><font size="2" color="#0000ff">&lt;</font><font size="2" color="#a31515">Grid</font><font size="2" color="#ff0000"> Name</font><font size="2" color="#0000ff">="dataGrid1"&gt;</font></font></font></font></font></code><code><font size="2" color="#0000ff"><font size="2" color="#0000ff">&lt;</font><font size="2" color="#a31515">xauto</font><font size="2" color="#0000ff">:</font><font size="2" color="#a31515">XceedAutoFitColumnGrid</font><font size="2"> </font><font size="2" color="#ff0000">Grid.Row</font><font size="2" color="#0000ff">="0"</font><font size="2" color="#ff0000"> x</font><font size="2" color="#0000ff">:</font><font size="2" color="#ff0000">Name</font><font size="2" color="#0000ff">="accountsGrid"</font><font size="2" color="#ff0000"> Margin</font><font size="2" color="#0000ff">="0,0,0,29"</font><font size="2"> </font><font size="2"><font size="2" color="#ff0000">AutoCreateColumns</font><font size="2" color="#0000ff">="False"</font><font size="2"><font size="2" color="#ff0000">EditTriggers</font><font size="2" color="#0000ff">="BeginEditCommand,ActivationGesture"</font><font size="2"> </font><font size="2" color="#0000ff">&gt;</font></font></font><font size="2"><font size="2" color="#a31515"><font size="2" color="#0000ff">&lt;</font><font size="2" color="#a31515">xcdg</font><font size="2" color="#0000ff">:</font><font size="2" color="#a31515">DataGridControl.Columns</font><font size="2" color="#0000ff">&gt;</font></font></font><font size="2"><font size="2" color="#a31515"><font size="2" color="#0000ff">&lt;</font><font size="2" color="#a31515">xcdg</font><font size="2" color="#0000ff">:</font><font size="2" color="#a31515">Column</font><font size="2" color="#ff0000"> FieldName</font><font size="2" color="#0000ff">="ACCOUNT"</font><font size="2" color="#ff0000"> ReadOnly</font><font size="2" color="#0000ff">="True"</font><font size="2" color="#ff0000"> Title</font><font size="2" color="#0000ff">="account"</font><font size="2"> </font><font size="2" color="#0000ff">/&gt;</font></font><font size="2" color="#a31515"><font size="2" color="#a31515"><font size="2" color="#0000ff">&lt;</font><font size="2" color="#a31515">xcdg</font><font size="2" color="#0000ff">:</font><font size="2" color="#a31515">Column</font><font size="2" color="#ff0000"> FieldName</font><font size="2" color="#0000ff">="DEPT"</font><font size="2" color="#ff0000"> ReadOnly</font><font size="2" color="#0000ff">="True"</font><font size="2" color="#ff0000"> Title</font><font size="2" color="#0000ff">="dept"</font><font size="2"> </font><font size="2" color="#0000ff">/&gt;</font></font></font></font><font size="2"> </font><font size="2" color="#a31515"><font size="2" color="#0000ff">&lt;</font><font size="2" color="#a31515">xcdg</font><font size="2" color="#0000ff">:</font><font size="2" color="#a31515">Column</font><font size="2" color="#ff0000"> FieldName</font><font size="2" color="#0000ff">="longvalue"</font><font size="2" color="#ff0000"> ReadOnly</font><font size="2" color="#0000ff">="True"</font><font size="2" color="#ff0000"> Title</font><font size="2" color="#0000ff">="longvalue"/&gt;</font></font><font size="2" color="#a31515"><font size="2" color="#a31515"><font size="2" color="#0000ff">&lt;</font><font size="2" color="#a31515">xcdg</font><font size="2" color="#0000ff">:</font><font size="2" color="#a31515">Column</font><font size="2" color="#ff0000"> FieldName</font><font size="2" color="#0000ff">="balance"</font><font size="2" color="#ff0000"> Title</font><font size="2" color="#0000ff">="balance" /&gt;</font></font></font><font size="2" color="#a31515"><font size="2" color="#a31515"><font size="2" color="#0000ff">&lt;</font><font size="2" color="#a31515">xcdg</font><font size="2" color="#0000ff">:</font><font size="2" color="#a31515">Column</font><font size="2" color="#ff0000"> FieldName</font><font size="2" color="#0000ff">="equity"</font><font size="2" color="#ff0000"> ReadOnly</font><font size="2" color="#0000ff">="True"</font><font size="2" color="#ff0000"> Title</font><font size="2" color="#0000ff">="equity"/&gt;</font></font><font size="2" color="#a31515"><font size="2" color="#a31515"><font size="2" color="#0000ff">&lt;</font><font size="2" color="#a31515">xcdg</font><font size="2" color="#0000ff">:</font><font size="2" color="#a31515">Column</font><font size="2" color="#ff0000"> FieldName</font><font size="2" color="#0000ff">="pending"</font><font size="2" color="#ff0000"> Title</font><font size="2" color="#0000ff">="pending"</font><font size="2"> </font><font size="2" color="#0000ff">/&gt;</font></font></font></font><font size="2" color="#a31515"><font size="2" color="#a31515"><font size="2" color="#0000ff">&lt;</font><font size="2" color="#a31515">xcdg</font><font size="2" color="#0000ff">:</font><font size="2" color="#a31515">Column</font><font size="2" color="#ff0000"> FieldName</font><font size="2" color="#0000ff">="reserves"</font><font size="2" color="#ff0000"> ReadOnly</font><font size="2" color="#0000ff">="True"</font><font size="2" color="#ff0000"> Title</font><font size="2" color="#0000ff">="reserves"</font><font size="2"> </font><font size="2" color="#0000ff">/&gt;</font></font><font size="2" color="#a31515"><font size="2" color="#a31515"><font size="2" color="#0000ff">&lt;/</font><font size="2" color="#a31515">xcdg</font><font size="2" color="#0000ff">:</font><font size="2" color="#a31515">DataGridControl.Columns</font><font size="2" color="#0000ff">&gt;</font></font></font><font size="2" color="#a31515"> </font><font size="2" color="#a31515"><font size="2" color="#0000ff">&lt;/</font><font size="2" color="#a31515">xauto</font><font size="2" color="#0000ff">:</font><font size="2" color="#a31515">XceedAutoFitColumnGrid</font><font size="2" color="#0000ff">&gt;</font></font><font size="2" color="#a31515"> </font><font size="2" color="#a31515"><font size="2" color="#0000ff">&lt;</font><font size="2" color="#a31515">Label</font><font size="2" color="#ff0000"> HorizontalAlignment</font><font size="2" color="#0000ff">="Left"</font><font size="2"> </font><font size="2" color="#ff0000">x</font><font size="2" color="#0000ff">:</font><font size="2" color="#ff0000">Name</font><font size="2" color="#0000ff">="label1"</font><font size="2" color="#ff0000"> VerticalAlignment</font><font size="2" color="#0000ff">="Bottom"</font><font size="2" color="#ff0000"> Width</font><font size="2" color="#0000ff">="201.63"</font><font size="2" color="#ff0000"> Height</font><font size="2" color="#0000ff">="23.2766666666667"&gt;</font><font size="2" color="#a31515">Label</font><font size="2" color="#0000ff">&lt;/</font><font size="2" color="#a31515">Label</font><font size="2" color="#0000ff">&gt;</font></font><font size="2" color="#a31515"><font size="2" color="#0000ff">&lt;/</font><font size="2" color="#a31515">Grid</font><font size="2" color="#0000ff">&gt;</font><font size="2" color="#0000ff">&lt;/<font size="2" color="#a31515">Window</font><font size="2" color="#0000ff">&gt;</font></font></font><font size="2" color="#a31515"><font size="2" color="#0000ff">The end result can be viewed at the top of the page.</font></font></font></p>
<p></font></code></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ajhorus.wordpress.com/16/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ajhorus.wordpress.com/16/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ajhorus.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ajhorus.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ajhorus.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ajhorus.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ajhorus.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ajhorus.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ajhorus.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ajhorus.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ajhorus.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ajhorus.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ajhorus.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ajhorus.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ajhorus.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ajhorus.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajhorus.wordpress.com&amp;blog=1055793&amp;post=16&amp;subd=ajhorus&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ajhorus.wordpress.com/2007/11/22/xceed-datagrid-custom-cell-styling/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d170e8724c0735e4740fe7a730470345?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ajhorus</media:title>
		</media:content>

		<media:content url="http://ajhorus.files.wordpress.com/2007/11/xceed_customcell1.jpg" medium="image">
			<media:title type="html">xceed_customcell1.jpg</media:title>
		</media:content>
	</item>
		<item>
		<title>Autosize Columns XceedDataGrid WPF</title>
		<link>http://ajhorus.wordpress.com/2007/11/08/autosize-columns-xceeddatagrid-wpf/</link>
		<comments>http://ajhorus.wordpress.com/2007/11/08/autosize-columns-xceeddatagrid-wpf/#comments</comments>
		<pubDate>Thu, 08 Nov 2007 19:28:29 +0000</pubDate>
		<dc:creator>ajhorus</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ajhorus.wordpress.com/2007/11/08/autosize-columns-xceeddatagrid-wpf/</guid>
		<description><![CDATA[Hello Everyone, I know its been a while, but to recent major events in my life i have been caught up.  Either way I am back.  Today I will show you a very useful and practical solution to autosize the columns in the XceedDataGrid fro wpf.   There is a property in the columns of the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajhorus.wordpress.com&amp;blog=1055793&amp;post=15&amp;subd=ajhorus&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hello Everyone, I know its been a while, but to recent major events in my life i have been caught up.  Either way I am back.  Today I will show you a very useful and practical solution to autosize the columns in the XceedDataGrid fro wpf. </p>
<p> There is a property in the columns of the grid that returns the best fitted width of the columns.  Apparently this would be as simple as calling this function and setting the width of the column to the result of the fucntion; however there a couple of issues to consider. Otherwise, the function would return -1.</p>
<p>- <strong>The function must be called after the layout of the grid has been updated</strong>.  In order to do this we must called it before setting the itemsource of the DataGrid. </p>
<p>Below there is a implementation of  custom class that inherits from XceedDataGrid and automatically autosized the columns:</p>
<p><code>public class XceedAutoFitColumnGrid : Xceed.Wpf.DataGrid.DataGridControl<br />
  {<br />
  private bool RunAutoFit = false;</code><code>public XceedAutoFitColumnGrid(): base()<br />
  {</code><code>this.LayoutUpdated += new EventHandler(Grid_LayoutUpdated);</p>
<p>}<br />
  private void Grid_LayoutUpdated(object sender, EventArgs e)<br />
  {<br />
  if (this.RunAutoFit)<br />
  {<br />
  AutoFit();<br />
  this.RunAutoFit = false;<br />
  }<br />
  }</p>
<p>public void AutoFit()<br />
  {<br />
  foreach (Column col in this.Columns)<br />
  {<br />
  double fittedWidth = col.GetFittedWidth();<br />
  if (fittedWidth &gt; 0) col.Width = fittedWidth + 2;<br />
  }<br />
  }<br />
  protected override void OnItemsSourceChanged(System.Collections.IEnumerable oldValue, System.Collections.IEnumerable newValue)<br />
  {<br />
  UpdateLayout();<br />
  base.OnItemsSourceChanged(oldValue, newValue);<br />
  if (this.AutoCreateColumns) this.RunAutoFit = true;<br />
  }</p>
<p>}</p>
<p></code></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ajhorus.wordpress.com/15/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ajhorus.wordpress.com/15/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ajhorus.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ajhorus.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ajhorus.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ajhorus.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ajhorus.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ajhorus.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ajhorus.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ajhorus.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ajhorus.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ajhorus.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ajhorus.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ajhorus.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ajhorus.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ajhorus.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajhorus.wordpress.com&amp;blog=1055793&amp;post=15&amp;subd=ajhorus&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ajhorus.wordpress.com/2007/11/08/autosize-columns-xceeddatagrid-wpf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d170e8724c0735e4740fe7a730470345?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ajhorus</media:title>
		</media:content>
	</item>
		<item>
		<title>Generics &#8211; List Custom Sorting</title>
		<link>http://ajhorus.wordpress.com/2007/07/20/generics-list-custom-sorting/</link>
		<comments>http://ajhorus.wordpress.com/2007/07/20/generics-list-custom-sorting/#comments</comments>
		<pubDate>Fri, 20 Jul 2007 16:15:14 +0000</pubDate>
		<dc:creator>ajhorus</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ajhorus.wordpress.com/2007/07/20/generics-list-custom-sorting/</guid>
		<description><![CDATA[Although the concept of templates is not quite new,  the particular implementation of templates done by Generics is quite nice.  I love working with them, they have proven to be very useful and flexible.  If you have not used them before, you should give it a try.  For this shor example, we will covering one [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajhorus.wordpress.com&amp;blog=1055793&amp;post=14&amp;subd=ajhorus&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Although the concept of templates is not quite new,  the particular implementation of templates done by Generics is quite nice.  I love working with them, they have proven to be very useful and flexible.  If you have not used them before, you should give it a try.</p>
<p> For this shor example, we will covering one of the useful advantages of the Generic List&lt; &gt;</p>
<p><strong>Custom Sorting</strong><code><br />
public class Student<br />
{</code><code> </code><code>//For Simplicit purposes these are public<br />
public int age;<br />
public string name;<br />
public string id;</p>
<p>public Student(int _age, string _name, string _id)<br />
{<br />
age = _age;<br />
name = _name;<br />
id = _id;</p>
<p>}</p>
<p>public override string ToString()<br />
{<br />
string s = age + "\n" + name + "\n" + id + "\n";<br />
return s;<br />
}</p>
<p>}</p>
<p></code>Now we have the class, need to create and instanciate our list of students and add students</p>
<p><code><br />
//Declare static since this is called from a console application<br />
public static List studentList ;</code><code>public static void AddStudents()<br />
{<br />
Student student1 = new Student(20, "Bolton", "M");<br />
Student student2 = new Student(20, "Abel", "M");<br />
Student student3 = new Student(21, "Catherine", "1234");<br />
Student student4 = new Student(21, "Catherine", "1111");<br />
Student student5 = new Student(22, "Bart", "M");</p>
<p>studentList.Add(student1);<br />
studentList.Add(student2);<br />
studentList.Add(student3);</p>
<p>studentList.Add(student4);<br />
studentList.Add(student5);</p>
<p>}</p>
<p></code>Now lets go unto sorting our list, this is the interesting part.<br />
<code><br />
public static int SortStudents(Student leftStudent, Student rightStudent)<br />
{<br />
   //sort first by Age<br />
   if (leftStudent.age &gt; rightStudent.age)<br />
       return 1;<br />
   else if (leftStudent.age &lt; rightStudent.age)<br />
       return -1;<br />
   else //if both students has the same age<br />
   {<br />
       //sort by name<br />
      if (leftStudent.name.CompareTo(rightStudent.name) != 0)<br />
     {<br />
          return leftStudent.name.CompareTo(rightStudent.name);<br />
     }<br />
     else //if both students has the same name and age, sort by id<br />
     {<br />
          if (leftStudent.id.CompareTo(rightStudent.id) != 0)<br />
          {<br />
               return leftStudent.id.CompareTo(rightStudent.id);<br />
          }<br />
          else<br />
          {<br />
               //in case both students to compare have identical values for all three properties<br />
               return 0;<br />
          }</p>
<p>     }<br />
   }<br />
}</p>
<p></code><br />
The signature of this function is going to be similar for any object we would like to store in our List.<br />
We&#8217;ll return an static int, and have will have two parameters of the type we are storing in our List; in this particular example since our list is a List of student we have both parameters of types students. Inside the body of the function we can do any comparison that we want to. Keeping in mind that we always need to return 0 in case both objects have the same value for all their properties. And that is, custom sorting of the objects store in any List.</p>
<p>Below the complete code for our console application example<br />
<code><br />
namespace ListCustomSort<br />
{<br />
class Program<br />
{</code><code>public static List studentList ;<br />
static void Main(string[] args)<br />
{<br />
studentList = new List();<br />
AddStudents();<br />
DisplayStudents();</p>
<p>Console.WriteLine("Sorting students");</p>
<p>studentList.Sort(SortStudents);</p>
<p>DisplayStudents();</p>
<p>}</p>
<p>public static void DisplayStudents()<br />
{<br />
foreach(Student student in studentList)<br />
{<br />
Console.Write(student.ToString());<br />
Console.WriteLine("-------------------");<br />
}<br />
}</p>
<p>public static void AddStudents()<br />
{<br />
Student student1 = new Student(20, "Bolton", "M");<br />
Student student2 = new Student(20, "Abel", "M");<br />
Student student3 = new Student(21, "Catherine", "1234");<br />
Student student4 = new Student(21, "Catherine", "1111");<br />
Student student5 = new Student(22, "Bart", "M");</p>
<p>studentList.Add(student1);<br />
studentList.Add(student2);<br />
studentList.Add(student3);<br />
studentList.Add(student4);<br />
studentList.Add(student5);</p>
<p>}</p>
<p>public static int SortStudents(Student leftStudent, Student rightStudent)<br />
{<br />
//sort first by Age<br />
if (leftStudent.age &gt; rightStudent.age)<br />
return 1;<br />
else if (leftStudent.age &lt; rightStudent.age)<br />
return -1;<br />
else //if both students has the same age<br />
{<br />
//sort by name<br />
if (leftStudent.name.CompareTo(rightStudent.name) != 0)<br />
{<br />
return leftStudent.name.CompareTo(rightStudent.name);<br />
}<br />
else //if both students has the same name and age, sort by id<br />
{<br />
if (leftStudent.id.CompareTo(rightStudent.id) != 0)<br />
{<br />
return leftStudent.id.CompareTo(rightStudent.id);<br />
}<br />
else<br />
{<br />
//in case both students to compare have identical values for all three properties<br />
return 0;<br />
}</p>
<p>}</p>
<p>}<br />
}</p>
<p>}<br />
}</p>
<p></code></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ajhorus.wordpress.com/14/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ajhorus.wordpress.com/14/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ajhorus.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ajhorus.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ajhorus.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ajhorus.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ajhorus.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ajhorus.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ajhorus.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ajhorus.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ajhorus.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ajhorus.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ajhorus.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ajhorus.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ajhorus.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ajhorus.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajhorus.wordpress.com&amp;blog=1055793&amp;post=14&amp;subd=ajhorus&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ajhorus.wordpress.com/2007/07/20/generics-list-custom-sorting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d170e8724c0735e4740fe7a730470345?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ajhorus</media:title>
		</media:content>
	</item>
		<item>
		<title>Read and Write XML &#8211; Isolated Storage</title>
		<link>http://ajhorus.wordpress.com/2007/07/16/read-and-write-xml-isolated-storage/</link>
		<comments>http://ajhorus.wordpress.com/2007/07/16/read-and-write-xml-isolated-storage/#comments</comments>
		<pubDate>Mon, 16 Jul 2007 22:05:38 +0000</pubDate>
		<dc:creator>ajhorus</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ajhorus.wordpress.com/2007/07/16/read-and-write-xml-isolated-storage/</guid>
		<description><![CDATA[Usually there is certain user related  info we would like to store in other place rather than the database.  For this task, we have several options, storing a a regular file, using the registry to save the settings, and so on. The .Net framework also gives us the choice to use Isolated Storage,  basically the .Net handles [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajhorus.wordpress.com&amp;blog=1055793&amp;post=13&amp;subd=ajhorus&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Usually there is certain user related  info we would like to store in other place rather than the database.  For this task, we have several options, storing a a regular file, using the registry to save the settings, and so on.</p>
<p>The .Net framework also gives us the choice to use <strong>Isolated Storage,  </strong>basically the .Net handles the location of the file and its different for os user and for application.  I won&#8217;t go into the details of the Isolated Storage mechanism, but if you would like to have more info visit this link</p>
<p><a href="http://msdn2.microsoft.com/en-us/library/3ak841sy(VS.80).aspx">Msdn Isolated Storage</a></p>
<p>For this example we would write the info of a DataSet to a xml file using Isolated Storage.<br />
Writting part:<br />
<code></code><code>//Get the isolated store for this assembly<br />
isf = IsolatedStorageFile.GetUserStoreForAssembly();</code><code>//Create a file at the top level of the store<br />
isfStream = new IsolatedStorageFileStream("DB_Dump.xml", FileMode.OpenOrCreate, FileAccess.Write, isf);</p>
<p>//Create our streamwritter to write content to the file<br />
StreamWriter sw = new StreamWriter(isfStream);</p>
<p>//assign a table to datatable<br />
DataTable dt = ds.Tables[0];</p>
<p>//Write the content of the datatable to my xml file<br />
dt.WriteXml(sw,XmlWriteMode.WriteSchema);</p>
<p>//it is very important to include the XmlWriteMode.WriteSchema,</p>
<p>//otherwise we'll get errors reading the xml file</p>
<p></code>Now for the reading part:<br />
<code></code><code>//Get the isolated store for this assembly<br />
isf = IsolatedStorageFile.GetUserStoreForAssembly();</code><code>//Open a file at the top level of the store<br />
isfStream = new IsolatedStorageFileStream("DB_Dump.xml", FileMode.Open, FileAccess.Read, isf);</p>
<p>//Our streamreader to read data<br />
StreamReader sr = new StreamReader(isfStream);</p>
<p>//assign a table to datatable<br />
DataTable dt = new DataTable();</p>
<p>dt.ReadXml(sr.ReadToEnd());</p>
<p></code></p>
<p>As you can see, its pretty straightforward. The only special consideration is setting the XmlWriteMode to Write Schema. </p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ajhorus.wordpress.com/13/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ajhorus.wordpress.com/13/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ajhorus.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ajhorus.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ajhorus.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ajhorus.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ajhorus.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ajhorus.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ajhorus.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ajhorus.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ajhorus.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ajhorus.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ajhorus.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ajhorus.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ajhorus.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ajhorus.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajhorus.wordpress.com&amp;blog=1055793&amp;post=13&amp;subd=ajhorus&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ajhorus.wordpress.com/2007/07/16/read-and-write-xml-isolated-storage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d170e8724c0735e4740fe7a730470345?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ajhorus</media:title>
		</media:content>
	</item>
		<item>
		<title>DataGridView Data Entry Validation</title>
		<link>http://ajhorus.wordpress.com/2007/07/04/datagridview-data-entry-validation/</link>
		<comments>http://ajhorus.wordpress.com/2007/07/04/datagridview-data-entry-validation/#comments</comments>
		<pubDate>Wed, 04 Jul 2007 20:41:08 +0000</pubDate>
		<dc:creator>ajhorus</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>

		<guid isPermaLink="false">http://ajhorus.wordpress.com/2007/07/04/datagridview-data-entry-validation/</guid>
		<description><![CDATA[I faced this issue a couple of times. How to efectively validate data entry inside a DataGridView.  Well, after doing some research and a bit of trial and error, found out a couple of approaches.  - Immediate validation:  For those of you who have used dynamic regular expression validator in c#.  This method is pretty [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajhorus.wordpress.com&amp;blog=1055793&amp;post=11&amp;subd=ajhorus&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I faced this issue a couple of times. How to efectively validate data entry inside a DataGridView.  Well, after doing some research and a bit of trial and error, found out a couple of approaches. </p>
<p>- <strong>Immediate validation:</strong>  For those of you who have used dynamic regular expression validator in c#.  This method is pretty similar.  It checks on the fly the data enter by the user.   Msdn has a nice article on how to implemented. </p>
<p><a href="http://msdn2.microsoft.com/en-us/library/7ehy30d4(VS.80).aspx">http://msdn2.microsoft.com/en-us/library/7ehy30d4(VS.80).aspx</a></p>
<p>- <strong>LateValidation:</strong> This validation is performed after the user is done entering data.  For the specific project i was working in, it was the perfect choice. However, one has to evaluate the pros and cons of each one.</p>
<p>If you are going to perform complex and multiple validation, you should try the second approach. Also this approach allows the user more flexibility. Lets say the user its not required to enter data in all the rows of the datagridview, the latter approach would work just fine.</p>
<p>On the other hand, if the user is required to enter data in all the rows and the validation is simple; the first approach is convenient.  </p>
<p>In order to implement <strong>Immediate validation</strong>, the event CellValidation must be handled</p>
<p>Ex<br />
<code><br />
 private void dataGridView1_CellValidating(object sender,<br />
  DataGridViewCellValidatingEventArgs e)<br />
  {<br />
  // Validate the CompanyName entry by disallowing empty strings.<br />
  if (dataGridView1.Columns[e.ColumnIndex].Name == "CompanyName")<br />
  {<br />
  if (String.IsNullOrEmpty(e.FormattedValue.ToString())  &amp;&amp;<br />
  dataGridView1[e.ColumnIndex,e.RowIndex].IsInEditMode )<br />
  {<br />
  dataGridView1.Rows[e.RowIndex].ErrorText =<br />
  "Company Name must not be empty";<br />
       //e.Cancel = true;</code></p>
<p><code><br />
  }<br />
  }<br />
  }</code></p>
<p>The validation to check if the cell is in edit mode is very important. Keep that in mind.</p>
<p>For the Late Validation, there must be an event that is perform once the user finish entering data.  In the implementation of this event,  we would have to go through all the rows that have any info on them and perform the validation required, setting the appropiate error messages in the cell.ErrorMessage property.</p>
<p> Ex<br />
<code><br />
foreach(DataGridViewRow mRow in datagrid.Rows)</code><code>{</p>
<p>if (!Double.TryParse(mRow.Cells["Lots of amount"].FormattedValue.ToString(), out result))</p>
<p>{</p>
<p>mRow.Cells["Lots of amount"].ErrorText = "Please enter a valid number";</p>
<p>//flag to indicate there is an error</p>
<p>error = true;</p>
<p>}</p>
<p>}</p>
<p></code></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ajhorus.wordpress.com/11/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ajhorus.wordpress.com/11/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ajhorus.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ajhorus.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ajhorus.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ajhorus.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ajhorus.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ajhorus.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ajhorus.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ajhorus.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ajhorus.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ajhorus.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ajhorus.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ajhorus.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ajhorus.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ajhorus.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajhorus.wordpress.com&amp;blog=1055793&amp;post=11&amp;subd=ajhorus&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ajhorus.wordpress.com/2007/07/04/datagridview-data-entry-validation/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d170e8724c0735e4740fe7a730470345?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ajhorus</media:title>
		</media:content>
	</item>
		<item>
		<title>Panama .Net UserGroup</title>
		<link>http://ajhorus.wordpress.com/2007/05/28/panama-net-usergroup/</link>
		<comments>http://ajhorus.wordpress.com/2007/05/28/panama-net-usergroup/#comments</comments>
		<pubDate>Mon, 28 May 2007 14:52:24 +0000</pubDate>
		<dc:creator>ajhorus</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://ajhorus.wordpress.com/2007/05/28/panama-net-usergroup/</guid>
		<description><![CDATA[Last week I have the opportunity to attend one of the meeting of the .Net Usergroup of Panama.  This group have been around for a couple of years now.  Usually they meet weekly, sometimes every 15 days.  In this group they  cover serveral topics of interest related to the .Net technology.   For instance,  last week [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajhorus.wordpress.com&amp;blog=1055793&amp;post=9&amp;subd=ajhorus&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Last week I have the opportunity to attend one of the meeting of the .Net Usergroup of Panama.  This group have been around for a couple of years now.  Usually they meet weekly, sometimes every 15 days.  In this group they  cover serveral topics of interest related to the .Net technology.   For instance,  last week they cover a couples of odrm that can be used with .net such as:  n-hibernate and ibatis.  The presentation of this two topics was quite good. The speaker knew his stuff. </p>
<p>After they cover the basic approach for setting up a WFC  service.  Although the speaker had a clear knowledge of this topic, by rushing through the presentation he was not able to fully explained this interesting topic.   It would have been nice to cover it in more detail.  </p>
<p>In general the presentation was quite nice!!!!</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ajhorus.wordpress.com/9/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ajhorus.wordpress.com/9/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ajhorus.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ajhorus.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ajhorus.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ajhorus.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ajhorus.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ajhorus.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ajhorus.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ajhorus.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ajhorus.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ajhorus.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ajhorus.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ajhorus.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ajhorus.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ajhorus.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajhorus.wordpress.com&amp;blog=1055793&amp;post=9&amp;subd=ajhorus&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ajhorus.wordpress.com/2007/05/28/panama-net-usergroup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d170e8724c0735e4740fe7a730470345?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ajhorus</media:title>
		</media:content>
	</item>
		<item>
		<title>The Code Police: FXCop</title>
		<link>http://ajhorus.wordpress.com/2007/05/08/the-code-police-fxcop/</link>
		<comments>http://ajhorus.wordpress.com/2007/05/08/the-code-police-fxcop/#comments</comments>
		<pubDate>Tue, 08 May 2007 21:19:53 +0000</pubDate>
		<dc:creator>ajhorus</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>

		<guid isPermaLink="false">http://ajhorus.wordpress.com/2007/05/08/the-code-police-fxcop/</guid>
		<description><![CDATA[One of the common issues programmers face is qa (quality assurance).  Usually this labor involves x amount of resources that focus on testing the application extensively.   As you can imagine, this labor is time consuming and error prone.  An easy alternative for this issue is FXCOP. FXCOP is a code analytical tool for .net managed code.  [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajhorus.wordpress.com&amp;blog=1055793&amp;post=8&amp;subd=ajhorus&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One of the common issues programmers face is qa (quality assurance).  Usually this labor involves x amount of resources that focus on testing the application extensively.   As you can imagine, this labor is time consuming and error prone. </p>
<p>An easy alternative for this issue is <strong>FXCOP. </strong></p>
<p><strong>FXCOP </strong>is a code analytical tool for .net managed code.  It checks that the code complies to Microsoft .NET Framework Design Guidelines.    It does so, by loading the compiled assembly of the code you want to check.  There is not code test writting involve. Just run <strong>FXCOP</strong>, open the code assembly you want to check and that&#8217;s it.</p>
<p>Usual areas that <strong>FXCOP</strong> covers include:</p>
<li>Library design</li>
<li>Localization</li>
<li>Naming conventions</li>
<li>Performance</li>
<li>Security</li>
<p>Besides identifying the error or warning we are incurring into, it also give us the exact line of this error and a possible solution for it. While some of this adviced solutions are pretty straight forward, others need a little bit thought to actually implement correctly. </p>
<p>By using this tool we can produce secure application of improved quality. </p>
<p> Happy Blogging!!!</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ajhorus.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ajhorus.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ajhorus.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ajhorus.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ajhorus.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ajhorus.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ajhorus.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ajhorus.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ajhorus.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ajhorus.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ajhorus.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ajhorus.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ajhorus.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ajhorus.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ajhorus.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ajhorus.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ajhorus.wordpress.com&amp;blog=1055793&amp;post=8&amp;subd=ajhorus&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ajhorus.wordpress.com/2007/05/08/the-code-police-fxcop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d170e8724c0735e4740fe7a730470345?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ajhorus</media:title>
		</media:content>
	</item>
	</channel>
</rss>
