<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>David Kline : Quick Tips</title><link>http://blogs.msdn.com/davidklinems/archive/tags/Quick+Tips/default.aspx</link><description>Tags: Quick Tips</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Quick Tip: Add files to Visual Studio projects the easy way</title><link>http://blogs.msdn.com/davidklinems/archive/2007/12/18/quick-tip-add-files-to-visual-studio-projects-the-easy-way.aspx</link><pubDate>Wed, 19 Dec 2007 01:58:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6800215</guid><dc:creator>DavidKlineMS</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/davidklinems/comments/6800215.aspx</comments><wfw:commentRss>http://blogs.msdn.com/davidklinems/commentrss.aspx?PostID=6800215</wfw:commentRss><description>&lt;p&gt;Here's another in my series of &amp;quot;why didn't I know this feature was there&amp;quot;.    &lt;br /&gt;    &lt;br /&gt;While I was doing a technical review last week, I learned about a much easier way to add files to my Visual Studio projects.     &lt;br /&gt;    &lt;br /&gt;In the solution explorer&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Select a project &lt;/li&gt;    &lt;li&gt;Click the &amp;quot;Show all files&amp;quot; button &lt;/li&gt;    &lt;li&gt;Right-click on the desired file (will be shown with an empty document icon) &lt;/li&gt;    &lt;li&gt;Click the &amp;quot;Include in project&amp;quot; menu item &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;This is so much easier than my usual technique (Add | Existing Item...).    &lt;br /&gt;    &lt;br /&gt;Take care!     &lt;br /&gt;-- DK     &lt;br /&gt;    &lt;br /&gt;&lt;font size="1"&gt;[Edit: fix spelling]      &lt;br /&gt;      &lt;br /&gt;Disclaimer(s):       &lt;br /&gt;This posting is provided &amp;quot;AS IS&amp;quot; with no warranties, and confers no rights.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6800215" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/davidklinems/archive/tags/Tips+and+Tricks/default.aspx">Tips and Tricks</category><category domain="http://blogs.msdn.com/davidklinems/archive/tags/Quick+Tips/default.aspx">Quick Tips</category></item><item><title>Quick Tip: Debugging Smart Device Unit Tests</title><link>http://blogs.msdn.com/davidklinems/archive/2007/11/12/quick-tip-debugging-smart-device-unit-tests.aspx</link><pubDate>Mon, 12 Nov 2007 21:54:08 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6147256</guid><dc:creator>DavidKlineMS</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/davidklinems/comments/6147256.aspx</comments><wfw:commentRss>http://blogs.msdn.com/davidklinems/commentrss.aspx?PostID=6147256</wfw:commentRss><description>&lt;p&gt;While browsing &lt;a href="http://msdn2.microsoft.com"&gt;MSDN&lt;/a&gt; today, I came upon a handy article that I wanted to share.&amp;#160;&amp;#160; Titled &lt;a href="http://msdn2.microsoft.com/en-us/library/bb513875(VS.90).aspx"&gt;'How to: Debug while Running a Smart Device Unit Test&lt;/a&gt;', it provides step by step instructions on debugging your test projects.     &lt;br /&gt;    &lt;br /&gt;There is one additional step I would like to add to those listed in the article.     &lt;br /&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;table bordercolor="#800080" cellspacing="0" cellpadding="2" width="60%" border="1"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="398"&gt;&lt;strong&gt;WARNING&lt;/strong&gt;: Using Remote Registry Editor incorrectly can cause serious problems that may require you to hard reset your device. Microsoft cannot guarantee that problems resulting from the incorrect use of Remote Registry Editor can be solved. Use Remote Registry Editor at your own risk.&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;   &lt;br /&gt;7. Disable support for attaching to managed processes     &lt;br /&gt;To do this, use the Visual Studio Remote Registry Editor:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;a. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETCompactFramework      &lt;br /&gt;b. Set the value of Managed Debugger\AttachEnabled to 0       &lt;br /&gt;-or-       &lt;br /&gt;Delete the Managed Debugger node&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Take care!    &lt;br /&gt;-- DK     &lt;br /&gt;    &lt;br /&gt;&lt;font face="Arial" size="1"&gt;Disclaimer(s):      &lt;br /&gt;This posting is provided &amp;quot;AS IS&amp;quot; with no warranties, and confers no rights.       &lt;br /&gt;The information contained within this post is in relation to beta software.&amp;#160; Any and all details are subject to change.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6147256" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/davidklinems/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://blogs.msdn.com/davidklinems/archive/tags/Tips+and+Tricks/default.aspx">Tips and Tricks</category><category domain="http://blogs.msdn.com/davidklinems/archive/tags/Quick+Tips/default.aspx">Quick Tips</category></item><item><title>Quick Tip: Getting the Collection of Checked ListView Items</title><link>http://blogs.msdn.com/davidklinems/archive/2007/06/18/quick-tip-getting-the-collection-of-checked-listview-items.aspx</link><pubDate>Mon, 18 Jun 2007 21:09:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3387821</guid><dc:creator>DavidKlineMS</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/davidklinems/comments/3387821.aspx</comments><wfw:commentRss>http://blogs.msdn.com/davidklinems/commentrss.aspx?PostID=3387821</wfw:commentRss><description>&lt;P&gt;Have you ever created a ListView control and wanted to get the collection of items that the user has checked?&amp;nbsp; While I was working on my demo for MEDC, that was one of the things that I needed to be able to do.&amp;nbsp; If I were writing my application for the .NET Framework, I would get the collection of items via the ListView.CheckedItems property.&amp;nbsp; When I looked up ListView in the MSDN documentation, I found that the CheckedItems property is not supported on the &lt;A href="http://blogs.msdn.com/netcfteam" mce_href="http://blogs.msdn.com/netcfteam"&gt;.NET Compact Framework&lt;/A&gt;.&amp;nbsp; As a result, I was going to need to create the collection myself.&amp;nbsp; Or was I?&lt;BR&gt;&lt;BR&gt;Since the application that I was writing was a demonstration of the cool new features of .NET Compact Framework version 3.5, I decided to try my hand a using Language Integrated Query, specifically LINQ to Objects.&amp;nbsp; The resulting code was small, worked well and was quite easy to read.&amp;nbsp; Let's take a look at what I wrote.&lt;BR&gt;&lt;CODE&gt;&lt;BR&gt;public static List&amp;lt;ListViewItem&amp;gt; GetCheckedListViewItems(ListView lv)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;ListViewItem&amp;gt; checkedItems = (from ListViewItem lvi in lv.Items&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;where (true == lvi.Checked)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;select lvi).ToList();&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return checkedItems;&lt;BR&gt;}&lt;BR&gt;&lt;/CODE&gt;&lt;BR&gt;The method above is based on my Lunch Launcher demo application, as shown during the What's New in .NET Compact Framework version 3.5 session that I delivered at MEDC 2007 last month.&amp;nbsp;&amp;nbsp; How does it work?&amp;nbsp; First, we specify that we are interested in the ListViewItem objects contained within the ListView.Items property.&lt;BR&gt;&lt;CODE&gt;&lt;BR&gt;from ListViewItem lvi in lv.Items&lt;BR&gt;&lt;/CODE&gt;&lt;BR&gt;Next, we define the condition under which we are interested in the item, in our case when the item has been checked by the user.&lt;BR&gt;&lt;CODE&gt;&lt;BR&gt;where (true == lvi.Checked)&lt;BR&gt;&lt;/CODE&gt;&lt;BR&gt;Then we select the item.&lt;BR&gt;&lt;CODE&gt;&lt;BR&gt;select lvi&lt;BR&gt;&lt;/CODE&gt;&lt;BR&gt;Lastly, we call the ToList method to have the selected items returned to us as a List&amp;lt;ListViewItem&amp;gt;.&lt;BR&gt;&lt;BR&gt;Pretty neat and much nicer to read than a foreach loop.&amp;nbsp; If you have installed the &lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyID=1343d537-a62f-4a6e-9727-7791bf4cc2bd&amp;amp;DisplayLang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyID=1343d537-a62f-4a6e-9727-7791bf4cc2bd&amp;amp;DisplayLang=en"&gt;beta of .NET Compact Framework version 3.5&lt;/A&gt;, give LINQ a try and see how it can make your applications easier to write.&lt;BR&gt;&lt;BR&gt;Enjoy!&lt;BR&gt;-- DK&lt;BR&gt;&lt;BR&gt;&lt;FONT face=Arial size=1&gt;[Edit: fix formatting]&lt;BR&gt;&lt;BR&gt;Disclaimers:&lt;BR&gt;This posting is provided "AS IS" with no warranties, and confers no rights.&lt;BR&gt;The information contained within this post is in relation to beta software.&amp;nbsp; Any and all details are subject to change.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3387821" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/davidklinems/archive/tags/Tips+and+Tricks/default.aspx">Tips and Tricks</category><category domain="http://blogs.msdn.com/davidklinems/archive/tags/GUI/default.aspx">GUI</category><category domain="http://blogs.msdn.com/davidklinems/archive/tags/Quick+Tips/default.aspx">Quick Tips</category></item><item><title>Quick Tip: Using XPath to find nodes by attribute value</title><link>http://blogs.msdn.com/davidklinems/archive/2007/03/13/quick-tip-using-xpath-to-find-nodes-by-attribute-value.aspx</link><pubDate>Tue, 13 Mar 2007 21:11:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1874604</guid><dc:creator>DavidKlineMS</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/davidklinems/comments/1874604.aspx</comments><wfw:commentRss>http://blogs.msdn.com/davidklinems/commentrss.aspx?PostID=1874604</wfw:commentRss><description>&lt;P&gt;There are some things that I can just remember: phone numbers, locker combinations, and the like.&amp;nbsp; There are others that I have to lookup again and again and again.&amp;nbsp; XPath query syntax is one of the latter items.&amp;nbsp; Today, I'd like to talk a little about XPath queries.&lt;BR&gt;&lt;BR&gt;The following XML contains a collection of "Friend" nodes.&amp;nbsp; Each node has attributes for name and birth date.&amp;nbsp; To keep this post to a reasonable length, I am going to limit the XML to 5 nodes.&lt;BR&gt;&lt;BR&gt;&lt;CODE&gt;&amp;lt;MyFriends&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;Friend name="Sam" birthMonth="July"&amp;nbsp;birthDay="16" birthYear="1974" /&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;Friend name="Pam" birthMonth="April"&amp;nbsp;birthDay="7" birthYear="1967" /&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;Friend name="George" birthMonth="February"&amp;nbsp;birthDay="2" birthYear="1981" /&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;Friend name="John" birthMonth="April"&amp;nbsp;birthDay="11" birthYear="1972" /&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;Friend name="Martha" birthMonth="August"&amp;nbsp;birthDay="3" birthYear="1974" /&amp;gt;&lt;BR&gt;&amp;lt;/MyFriends&amp;gt;&lt;/CODE&gt;&lt;BR&gt;&lt;BR&gt;After loading this XML into an XmlDocument, I can use XPath to query for the nodes of interest.&lt;BR&gt;&lt;BR&gt;Since April is coming soon, I would like to get a list of my friends who has a birthday that month.&amp;nbsp; To do so, I query for Friend nodes where the value of the birthMonth attribute is "April".&lt;BR&gt;&lt;BR&gt;&lt;CODE&gt;// load the xml file into an XmlDocument&lt;BR&gt;XmlDocument doc = new XmlDocument();&lt;BR&gt;doc.Load("myfriends.xml");&lt;BR&gt;XmlElement rootNode = doc.DocumentElement;&lt;BR&gt;&lt;BR&gt;// select the friends who have a birthday in April&lt;BR&gt;String query = "Friend[@birthMonth='April']";&lt;BR&gt;XmlNodeList friends = rootNode.SelectNodes(query);&lt;BR&gt;&lt;BR&gt;foreach(XmlElement friend in friends)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // TODO: display a reminder to buy a birthday card&lt;BR&gt;}&lt;/CODE&gt;&lt;BR&gt;&lt;BR&gt;When the above snippet is run, two friends are returned: Pam and John.&amp;nbsp; The application can retrieve the desired information from the node and display an appropriate reminder.&lt;BR&gt;&lt;BR&gt;Enjoy!&lt;BR&gt;-- DK&lt;BR&gt;&lt;BR&gt;&lt;FONT size=1&gt;Edit: Fix grammar&lt;BR&gt;&lt;BR&gt;Disclaimer(s):&lt;BR&gt;This posting is provided "AS IS" with no warranties, and confers no rights.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1874604" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/davidklinems/archive/tags/Tips+and+Tricks/default.aspx">Tips and Tricks</category><category domain="http://blogs.msdn.com/davidklinems/archive/tags/XML/default.aspx">XML</category><category domain="http://blogs.msdn.com/davidklinems/archive/tags/Quick+Tips/default.aspx">Quick Tips</category></item><item><title>Quick Tip: Identifing the interfaces that an object implements</title><link>http://blogs.msdn.com/davidklinems/archive/2006/12/05/quick-tip-identifing-the-interfaces-that-an-object-implements.aspx</link><pubDate>Tue, 05 Dec 2006 22:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1212958</guid><dc:creator>DavidKlineMS</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/davidklinems/comments/1212958.aspx</comments><wfw:commentRss>http://blogs.msdn.com/davidklinems/commentrss.aspx?PostID=1212958</wfw:commentRss><description>Have you ever wondered what type an object is?&amp;nbsp; How about what interfaces the object implements?&amp;nbsp; Using the .NET Framework and .NET Compact Framework, this information is very easy to determine.&lt;BR&gt;&lt;BR&gt;The first thing we need to know about an object is it's type.&amp;nbsp; Every object, including Object, has a method called GetType().&amp;nbsp; For a given Object (obj), I get the Type (objType).&lt;BR&gt;&lt;BR&gt;&lt;CODE&gt;Type objType = obj.GetType();&lt;/CODE&gt;&lt;BR&gt;&lt;BR&gt;GetType naturally returns a Type object.&amp;nbsp; The Type object is, to me, one of the most useful objects in .NET.&amp;nbsp; From the Type object, you can determine if the object is public, is a generic type, is abstract, and more.&amp;nbsp; You can also get the name of the type.&lt;BR&gt;&lt;BR&gt;&lt;CODE&gt;String objTypeName = objType.ToString();&lt;/CODE&gt;&lt;BR&gt;&lt;BR&gt;When I called the above lines in a simple test application, the value of objTypeName was "System.Collections.Generic.List`1[System.String]", which tells me that obj is a List&amp;lt;String&amp;gt;.&lt;BR&gt;&lt;BR&gt;Once we have the type of our object, we can get the list of interfaces implemented by the object (List&amp;lt;String&amp;gt;).&lt;BR&gt;&lt;BR&gt;&lt;CODE&gt;Type[] objInterfaces = objType.GetInterfaces();&lt;/CODE&gt;&lt;BR&gt;&lt;BR&gt;To continue my example, by iterating over objInterfaces I see that List&amp;lt;String&amp;gt; implements:&lt;BR&gt;&lt;BR&gt;&lt;CODE&gt;System.Collections.Generic.IList`1[System.String]&lt;BR&gt;System.Collections.Generic.ICollection`1[System.String]&lt;BR&gt;System.Collections.Generic.IEnumerable`1[System.String]&lt;BR&gt;System.Collections.IList&lt;BR&gt;System.Collections.ICollection&lt;BR&gt;System.Collections.IEnumerable&lt;/CODE&gt;&lt;BR&gt;&lt;BR&gt;Knowing the interfaces implemented by a type can be useful in a variety of applications; from diagnostic tools to applications supporting plugins and more.&amp;nbsp; &lt;BR&gt;&lt;BR&gt;Enjoy!&lt;BR&gt;-- DK&lt;BR&gt;&lt;BR&gt;&lt;FONT size=1&gt;Disclaimer(s):&lt;BR&gt;This posting is provided "AS IS" with no warranties, and confers no rights.&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1212958" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/davidklinems/archive/tags/Tips+and+Tricks/default.aspx">Tips and Tricks</category><category domain="http://blogs.msdn.com/davidklinems/archive/tags/Quick+Tips/default.aspx">Quick Tips</category></item><item><title>Quick Tip - Sharing code between multiple projects in Visual Studio 2005</title><link>http://blogs.msdn.com/davidklinems/archive/2006/11/29/quick-tip-sharing-code-between-multiple-projects-in-visual-studio-2005.aspx</link><pubDate>Thu, 30 Nov 2006 04:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1175010</guid><dc:creator>DavidKlineMS</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/davidklinems/comments/1175010.aspx</comments><wfw:commentRss>http://blogs.msdn.com/davidklinems/commentrss.aspx?PostID=1175010</wfw:commentRss><description>I have long been an advocate for putting common code into an assembly that is shared by applications needing the functionality.&amp;nbsp; That said, there are times where the separate assembly approach is not appropriate.&amp;nbsp; For those situations, today's tip may help make code sharing easier.&lt;BR&gt;&lt;BR&gt;I have a project (called TestApp) that targets the .NET Compact Framework version 2.&amp;nbsp; In the TestApp project, there is a file called Helper.cs which implements a class containing static methods that I use throughout the TestApp project.&lt;BR&gt;&lt;BR&gt;While working on TestApp, I decide that a .NET Framework (for desktop PCs) version would be nice to have.&amp;nbsp; Since I already have Helper.cs written, I would like to use the existing version.&amp;nbsp; I had previously chosen to not use an assembly for these helpers, so I&amp;nbsp;add the existing file to my new project.&amp;nbsp; &lt;BR&gt;&lt;BR&gt;I would prefer to not create a duplicate of this file as maintaining changes between the two copies can be time consuming and error prone.&amp;nbsp; Fortunately, Visual Studio 2005 has a great feature to allow for file sharing between projects -- you can add an existing file as a link.&amp;nbsp; Here's how: 
&lt;OL&gt;
&lt;LI&gt;In the project where you wish to add the file, right click the project name in the &lt;STRONG&gt;Solution Explorer&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;Select &lt;STRONG&gt;Add&lt;/STRONG&gt; and then &lt;STRONG&gt;Existing Item...&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;In the &lt;STRONG&gt;Add Existing Item&lt;/STRONG&gt; dialog, navigate to the desired file&lt;/LI&gt;
&lt;LI&gt;Click the downward pointing arrow next to the &lt;STRONG&gt;Add&lt;/STRONG&gt; button and select &lt;STRONG&gt;Add As Link&lt;/STRONG&gt;.&lt;BR&gt;Once added to a project, linked files are easy to identify by the small arrow in the lower-left corner of the file icon in the Solution Explorer.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;My new project now has a reference to the original Helper.cs and any changes I make to it, from either project, are reflected in both projects.&lt;/P&gt;
&lt;TABLE class="" borderColor=#800080 cellSpacing=0 cellPadding=2 width="50%" border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class=""&gt;&lt;B&gt;Note:&lt;/B&gt; It is important to remember that if you are sharing a file between different versions of the .NET Framework, you need to verify that any changes made are compatible with all projects using the file.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;Enjoy!&lt;BR&gt;-- DK&lt;FONT size=1&gt;&lt;BR&gt;&lt;BR&gt;Disclaimer(s):&lt;BR&gt;This posting is provided "AS IS" with no warranties, and confers no rights.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1175010" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/davidklinems/archive/tags/Tips+and+Tricks/default.aspx">Tips and Tricks</category><category domain="http://blogs.msdn.com/davidklinems/archive/tags/Quick+Tips/default.aspx">Quick Tips</category></item><item><title>Quick Tip: Specifying a field's name when using the XmlSerializer</title><link>http://blogs.msdn.com/davidklinems/archive/2006/11/08/quick-tip-specifying-a-field-s-name-when-using-the-xmlserializer.aspx</link><pubDate>Wed, 08 Nov 2006 23:33:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1039693</guid><dc:creator>DavidKlineMS</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/davidklinems/comments/1039693.aspx</comments><wfw:commentRss>http://blogs.msdn.com/davidklinems/commentrss.aspx?PostID=1039693</wfw:commentRss><description>Last month, I wrote about how to &lt;A href="http://blogs.msdn.com/davidklinems/archive/2006/10/02/Quick-Tip_3A00_-Serializing-an-Object-Field-as-an-XML-Attribute.aspx" mce_href="http://blogs.msdn.com/davidklinems/archive/2006/10/02/Quick-Tip_3A00_-Serializing-an-Object-Field-as-an-XML-Attribute.aspx"&gt;instruct the XmlSerializer to create an XML attribute for fields in an object&lt;/A&gt;.&amp;nbsp; Today, I'd like to talk about how to specify the name used to represent a field in the resulting XML.&lt;BR&gt;&lt;BR&gt;By default, when an object is serialized, fields are serialized into nodes with names that match the name of the field.&amp;nbsp; When an instance of the example TestData object(below) is serialized&lt;BR&gt;&lt;BR&gt;&lt;CODE&gt;public class TestData&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public Int32 TestID;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public String Description;&lt;BR&gt;}&lt;/CODE&gt;&lt;BR&gt;&lt;BR&gt;the TestID and Description fields become&lt;BR&gt;&lt;BR&gt;&lt;CODE&gt;&amp;lt;TestID&amp;gt;0&amp;lt;/TestID&amp;gt;&lt;BR&gt;&amp;lt;Description&amp;gt;Sample test description.&amp;lt;/Description&amp;gt;&lt;/CODE&gt;&lt;BR&gt;&lt;BR&gt;At times, it may be desirable to change the default naming behavior.&amp;nbsp; To change the name, we decorate the TestID field with an XmlElement attribute.&lt;BR&gt;&lt;BR&gt;&lt;CODE&gt;[XmlElement(ElementName="ID")]&lt;BR&gt;public Int32 TestID;&lt;/CODE&gt;&lt;BR&gt;&lt;BR&gt;After serialization, the XML contains&lt;BR&gt;&lt;BR&gt;&lt;CODE&gt;&amp;lt;ID&amp;gt;0&amp;lt;/ID&amp;gt;&lt;/CODE&gt;&lt;BR&gt;&lt;BR&gt;This same technique also works with the XmlAttribute attribute.&lt;BR&gt;&lt;BR&gt;&lt;CODE&gt;[XmlAttribute(AttributeName="ID")]&lt;BR&gt;public Int32 TestID;&lt;/CODE&gt;&lt;BR&gt;&lt;BR&gt;Creates an attribute called ID (highlighted in &lt;FONT color=#800080&gt;purple&lt;/FONT&gt;) in the TestData node.&lt;BR&gt;&lt;BR&gt;&lt;CODE&gt;&amp;lt;TestData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" &lt;FONT color=#800080&gt;ID="0"&lt;/FONT&gt;&amp;gt;&lt;/CODE&gt;&lt;BR&gt;&lt;BR&gt;Enjoy!,&lt;BR&gt;-- DK&lt;BR&gt;&lt;BR&gt;&lt;FONT size=1&gt;Disclaimers:&lt;BR&gt;This posting is provided "AS IS" with no warranties, and confers no rights.&lt;BR&gt;&amp;nbsp;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1039693" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/davidklinems/archive/tags/Tips+and+Tricks/default.aspx">Tips and Tricks</category><category domain="http://blogs.msdn.com/davidklinems/archive/tags/XML/default.aspx">XML</category><category domain="http://blogs.msdn.com/davidklinems/archive/tags/Quick+Tips/default.aspx">Quick Tips</category></item><item><title>Quick Tip: Serializing an Object Field as an XML Attribute</title><link>http://blogs.msdn.com/davidklinems/archive/2006/10/02/Quick-Tip_3A00_-Serializing-an-Object-Field-as-an-XML-Attribute.aspx</link><pubDate>Tue, 03 Oct 2006 00:55:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:782023</guid><dc:creator>DavidKlineMS</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/davidklinems/comments/782023.aspx</comments><wfw:commentRss>http://blogs.msdn.com/davidklinems/commentrss.aspx?PostID=782023</wfw:commentRss><description>The addition of the XML Serializer is one of the reasons I really love version 2 of the .NET Compact Framework.&amp;nbsp; I use the XML Serializer in very nearly every application I write; to save application state, data files, etc.&amp;nbsp; By default, the XML Serializer will create a child node for every field in a type.&amp;nbsp; For example, the following object&lt;BR&gt;&lt;BR&gt;&lt;CODE&gt;public class TestData&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public Int32 TestID;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public String Description;&lt;BR&gt;}&lt;/CODE&gt;&lt;BR&gt;&lt;BR&gt;becomes&lt;BR&gt;&lt;BR&gt;&lt;CODE&gt;&amp;lt;TestData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;Description&amp;gt;Sample test description.&amp;lt;/Description&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;TestID&amp;gt;0&amp;lt;/TestID&amp;gt;&lt;BR&gt;&amp;lt;/TestData&amp;gt;&lt;/CODE&gt;&lt;BR&gt;&lt;BR&gt;There are times that you may wish to serialize one or more fields as attributes on the object's node (ex: reduce the size of the XML).&amp;nbsp; By decorating the TestID field with an &lt;A href="http://msdn2.microsoft.com/en-us/library/system.xml.serialization.xmlattributeattribute.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/system.xml.serialization.xmlattributeattribute.aspx"&gt;XmlAttribute&lt;/A&gt; attribute, the TestID field&lt;BR&gt;&lt;BR&gt;&lt;CODE&gt;[XmlAttribute()]&lt;BR&gt;public Int32 TestID;&lt;/CODE&gt;&lt;BR&gt;&lt;BR&gt;now becomes an attribute (highlighted in &lt;FONT color=#800080&gt;purple&lt;/FONT&gt;) on the TestData node.&lt;BR&gt;&lt;BR&gt;&lt;CODE&gt;&amp;lt;TestData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" &lt;FONT color=#800080&gt;TestID="0"&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;Description&amp;gt;Sample test description.&amp;lt;/Description&amp;gt;&lt;BR&gt;&amp;lt;/TestData&amp;gt;&lt;/CODE&gt;&lt;BR&gt;&lt;BR&gt;Enjoy!&lt;BR&gt;-- DK&lt;BR&gt;&lt;BR&gt;&lt;FONT size=1&gt;Disclaimers:&lt;BR&gt;This posting is provided "AS IS" with no warranties, and confers no rights.&lt;BR&gt;&amp;nbsp;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=782023" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/davidklinems/archive/tags/Tips+and+Tricks/default.aspx">Tips and Tricks</category><category domain="http://blogs.msdn.com/davidklinems/archive/tags/XML/default.aspx">XML</category><category domain="http://blogs.msdn.com/davidklinems/archive/tags/Quick+Tips/default.aspx">Quick Tips</category></item><item><title>Quick tip: Filtering input to a TextBox control</title><link>http://blogs.msdn.com/davidklinems/archive/2006/09/25/771140.aspx</link><pubDate>Mon, 25 Sep 2006 23:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:771140</guid><dc:creator>DavidKlineMS</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/davidklinems/comments/771140.aspx</comments><wfw:commentRss>http://blogs.msdn.com/davidklinems/commentrss.aspx?PostID=771140</wfw:commentRss><description>Sometimes, it's the little things that take the longest to work out, so I thought I'd start a "Quick tips" series.&amp;nbsp;&amp;nbsp;Quick tips are intended to be short and solve a very specific issue.&lt;BR&gt;&lt;BR&gt;I was talking with &lt;A href="https://blogs.msdn.com:443/markprenticems"&gt;Mark Prentice&lt;/A&gt; today and we were looking at filtering a TextBox control so that it only accepted numeric characters.&amp;nbsp; As it works out, this is a very easy thing to do with the .NET Compact Framework.&lt;BR&gt;&lt;BR&gt;To filter input that is entered into a TextBox, we need to implement a KeyPress event handler.&amp;nbsp; When you encounter a character you wish to exclude, set the value of &lt;A href="http://msdn2.microsoft.com/en-us/library/system.windows.forms.keypresseventargs.handled.aspx"&gt;KeyPressEventArgs.Handled&lt;/A&gt; to true.&amp;nbsp; To determine which characters to handle, the &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcharclasstopic.asp"&gt;Char&lt;/A&gt; type has several handy static methods that help determine&amp;nbsp;what type&amp;nbsp;of character was entered into a TextBox.&amp;nbsp; Since Mark and I were interested in limiting the input to only numeric characters, I will use &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcharclasstopic.asp"&gt;Char.IsDigit&lt;/A&gt; in my example.&lt;BR&gt;&lt;BR&gt;&lt;CODE&gt;private void textBox1_KeyPress(object sender, KeyPressEventArgs e)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // only allow numeric characters&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp; all other KeyPress events are cancelled&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; e.Handled = !Char.IsDigit(e.KeyCode);&lt;BR&gt;}&lt;/CODE&gt; 
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Enjoy!&lt;BR&gt;-- DK&lt;BR&gt;&lt;BR&gt;&lt;FONT size=1&gt;[Edit: fix sentence]&lt;BR&gt;&lt;BR&gt;Disclaimer(s): This posting is provided "AS IS" with no warranties, and confers no rights.&lt;/FONT&gt;&lt;/P&gt;&lt;FONT face="Courier New"&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=771140" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/davidklinems/archive/tags/Tips+and+Tricks/default.aspx">Tips and Tricks</category><category domain="http://blogs.msdn.com/davidklinems/archive/tags/Quick+Tips/default.aspx">Quick Tips</category></item></channel></rss>