﻿<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:blogChannel="http://backend.userland.com/blogChannelModule" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">
  <channel>
    <title>DogSpots - .Net Programming</title>
    <description>DogSpots is Bill Fugina and Debra Hill</description>
    <link>http://www.dogspots.com/DSBE/</link>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <generator>BlogEngine.NET 1.5.0.7</generator>
    <language>en-US</language>
    <blogChannel:blogRoll>http://www.dogspots.com/DSBE/opml.axd</blogChannel:blogRoll>
    <blogChannel:blink>http://www.dotnetblogengine.net/syndication.axd</blogChannel:blink>
    <dc:creator>DogSpots</dc:creator>
    <dc:title>DogSpots</dc:title>
    <geo:lat>0.000000</geo:lat>
    <geo:long>0.000000</geo:long>
    <item>
      <title>Programmatically check if SQL Replication Components are Installed</title>
      <description>&lt;p&gt;I spent some time this week tightening up the code in a project that will actually be released into the wild.&amp;nbsp; I wanted to make sure that I catch as many errors as possible and put up user friendly messages.&lt;/p&gt;
&lt;p&gt;The program uses &lt;a title="Microsoft" rel="nofollow" href="http://msdn.microsoft.com/en-us/library/ms162169.aspx" target="_blank"&gt;SMO&lt;/a&gt; and &lt;a title="Microsoft" rel="nofollow" href="http://msdn.microsoft.com/en-us/library/ms146869.aspx" target="_blank"&gt;RMO&lt;/a&gt; to synchronize a local &lt;a title="Microsoft" rel="nofollow" href="http://www.microsoft.com/Sqlserver/2005/en/us/express.aspx" target="_blank"&gt;SQL Express&lt;/a&gt; database with a master database over the internet.&amp;nbsp; The program would get some pretty cryptic error messages if SQL Express wasn&amp;rsquo;t installed, if the expected instance weren&amp;rsquo;t available or if the replication components weren&amp;rsquo;t installed.&lt;/p&gt;
&lt;p&gt;I was easily able to check if SQL Express was installed and to get a list of the installed instances, but I couldn&amp;rsquo;t find a way to check if the replication components were installed.&amp;nbsp; This was annoying because the replication components aren&amp;rsquo;t installed by default when SQL Express is installed and I was assuming that this situation would come up often.&lt;/p&gt;
&lt;p&gt;After some refactoring, I was able to get it to throw an exception with a pretty straight forward error message: &lt;em&gt;&amp;ldquo;Replication components are not installed on this server. Run SQL Server Setup again and select the option to install replication.&amp;rdquo;&amp;nbsp; &lt;/em&gt;In fact, I could catch the exception and put up whatever error message I wanted.&amp;nbsp; Unfortunately, this exception would not occur until the program spent quite a while preparing to do the synchronization.&amp;nbsp; I really wanted to check for the replication components &lt;em&gt;before&lt;/em&gt; I attempted any synchronization.&lt;/p&gt;
&lt;p&gt;I spent quite a while &lt;a title="Google" rel="nofollow" href="http://www.google.com/search?hl=en&amp;amp;rlz=1T4GGLL_enUS346US346&amp;amp;q=verify+that+replication+components+are+installed+on+SQL+server&amp;amp;aq=f&amp;amp;oq=&amp;amp;aqi=" target="_blank"&gt;googling&lt;/a&gt; trying to find something that would work, but couldn&amp;rsquo;t find anything.&amp;nbsp; Then I tried checking for the existence of several stored procedures, tables and entries in the SysObjects tables, but nothing I found on a server with the replication components was missing on one without them.&lt;/p&gt;
&lt;p&gt;Then I came across the &lt;strong&gt;sp_MS_replication_installed&lt;/strong&gt; system stored procedure.&amp;nbsp; It&amp;rsquo;s on all installations and tells exactly what I needed.&amp;nbsp; I was surprised that with all the searching I did, there was no mention of this handy stored procedure, so I figured I would do my part and document what I found.&lt;/p&gt;
&lt;p&gt;The stored procedure is simple enough in that it returns a 0 if the replication components are installed and a 1 if they aren&amp;rsquo;t.&amp;nbsp; However, under usual circumstances, it goes a step further and raises an exception if the components aren&amp;rsquo;t installed.&amp;nbsp; This is because the procedure reads an entry in the registry to see if the replication components are installed and if they aren&amp;rsquo;t, it is likely that the entry was never written in the first place.&amp;nbsp; When it can&amp;rsquo;t find the registry entry, an exception is thrown.&amp;nbsp; The only time the stored procedure would return a 1 without throwing an exception is if the replication components were installed at some point and then later uninstalled.&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="border: 1px solid silver; margin: 20px 0px 10px; padding: 4px; overflow: auto; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 98.48%; font-family: 'Courier New',courier,monospace; direction: ltr; height: 310px; max-height: 300px; font-size: 8pt; cursor: text;"&gt;
&lt;div id="codeSnippet" style="border-style: none; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;USE&lt;/span&gt; [master]&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum2" style="color: #606060"&gt;   2:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum3" style="color: #606060"&gt;   3:&lt;/span&gt; &lt;span style="color: #008000"&gt;/******Object:  StoredProcedure [sys].[sp_MS_replication_installed]******/&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum4" style="color: #606060"&gt;   4:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;SET&lt;/span&gt; ANSI_NULLS &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum5" style="color: #606060"&gt;   5:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum6" style="color: #606060"&gt;   6:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;SET&lt;/span&gt; QUOTED_IDENTIFIER &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum7" style="color: #606060"&gt;   7:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum8" style="color: #606060"&gt;   8:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum9" style="color: #606060"&gt;   9:&lt;/span&gt; &lt;span style="color: #008000"&gt;--&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum10" style="color: #606060"&gt;  10:&lt;/span&gt; &lt;span style="color: #008000"&gt;-- Name: sp_MS_replication_installed&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum11" style="color: #606060"&gt;  11:&lt;/span&gt; &lt;span style="color: #008000"&gt;--&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum12" style="color: #606060"&gt;  12:&lt;/span&gt; &lt;span style="color: #008000"&gt;-- Descriptions: &lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum13" style="color: #606060"&gt;  13:&lt;/span&gt; &lt;span style="color: #008000"&gt;--&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum14" style="color: #606060"&gt;  14:&lt;/span&gt; &lt;span style="color: #008000"&gt;-- Parameters: as defined in create statement&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum15" style="color: #606060"&gt;  15:&lt;/span&gt; &lt;span style="color: #008000"&gt;--&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum16" style="color: #606060"&gt;  16:&lt;/span&gt; &lt;span style="color: #008000"&gt;-- Returns: 0 - success&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum17" style="color: #606060"&gt;  17:&lt;/span&gt; &lt;span style="color: #008000"&gt;--          1 - Otherwise&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum18" style="color: #606060"&gt;  18:&lt;/span&gt; &lt;span style="color: #008000"&gt;--&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum19" style="color: #606060"&gt;  19:&lt;/span&gt; &lt;span style="color: #008000"&gt;-- Security: &lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum20" style="color: #606060"&gt;  20:&lt;/span&gt; &lt;span style="color: #008000"&gt;-- Requires Certificate signature for catalog access&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum21" style="color: #606060"&gt;  21:&lt;/span&gt; &lt;span style="color: #008000"&gt;--&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum22" style="color: #606060"&gt;  22:&lt;/span&gt; &lt;span style="color: #008000"&gt;ALTER procedure [sys].[sp_MS_replication_installed]&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum23" style="color: #606060"&gt;  23:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;as&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum24" style="color: #606060"&gt;  24:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;set&lt;/span&gt; nocount &lt;span style="color: #0000ff"&gt;on&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum25" style="color: #606060"&gt;  25:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;declare&lt;/span&gt; @isinstalled &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum26" style="color: #606060"&gt;  26:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;select&lt;/span&gt; @isinstalled = 0&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum27" style="color: #606060"&gt;  27:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;declare&lt;/span&gt; @retcode &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum28" style="color: #606060"&gt;  28:&lt;/span&gt;     &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum29" style="color: #606060"&gt;  29:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;EXECUTE&lt;/span&gt; @retcode = master.dbo.xp_instance_regread &lt;span style="color: #006080"&gt;'HKEY_LOCAL_MACHINE'&lt;/span&gt;, &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum30" style="color: #606060"&gt;  30:&lt;/span&gt;         &lt;span style="color: #006080"&gt;'SOFTWARE\Microsoft\MSSQLServer\Replication'&lt;/span&gt;,&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum31" style="color: #606060"&gt;  31:&lt;/span&gt;         &lt;span style="color: #006080"&gt;'IsInstalled'&lt;/span&gt;,&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum32" style="color: #606060"&gt;  32:&lt;/span&gt;         @param = @isinstalled &lt;span style="color: #0000ff"&gt;OUTPUT&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum33" style="color: #606060"&gt;  33:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum34" style="color: #606060"&gt;  34:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;IF&lt;/span&gt; ( @retcode &amp;lt;&amp;gt; 0 ) &lt;span style="color: #0000ff"&gt;or&lt;/span&gt; ( &lt;span style="color: #cc6633"&gt;@@ERROR&lt;/span&gt; &amp;lt;&amp;gt; 0 ) &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum35" style="color: #606060"&gt;  35:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;begin&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum36" style="color: #606060"&gt;  36:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;raiserror&lt;/span&gt; (21028, 16, -1)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum37" style="color: #606060"&gt;  37:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; (0)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum38" style="color: #606060"&gt;  38:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum39" style="color: #606060"&gt;  39:&lt;/span&gt;     &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum40" style="color: #606060"&gt;  40:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (@isinstalled &lt;span style="color: #0000ff"&gt;is&lt;/span&gt; &lt;span style="color: #0000ff"&gt;null&lt;/span&gt; &lt;span style="color: #0000ff"&gt;or&lt;/span&gt; @isinstalled = 0)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum41" style="color: #606060"&gt;  41:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;begin&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum42" style="color: #606060"&gt;  42:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;raiserror&lt;/span&gt; (21028, 16, -1)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum43" style="color: #606060"&gt;  43:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; (0)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum44" style="color: #606060"&gt;  44:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum45" style="color: #606060"&gt;  45:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum46" style="color: #606060"&gt;  46:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; (1)&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="CopyToClipboardOuter" &gt;&lt;div class="CopyToClipboardInner"&gt;&lt;a href="javascript:void(0);" title="View Plain" onclick="CopyToClipboard_ViewPlain(copyToClipboardeee985c9adfd4b5b9e288ce25d06f1c7_21755);"&gt;View Plain&lt;/a&gt; &lt;/div&gt;&lt;/div&gt;
				&lt;div id="CopyToClipboard_Hidden" style="display:none;"&gt;&lt;/div&gt;
				&lt;div id="CopyToClipboard_FlashContainer"&gt;&lt;/div&gt;
                &lt;script type="text/javascript"&gt;

					function CopyToClipboard_Strip( text ){
						text = text.replace( /&amp;nbsp;/g, ' ' );
						text = text.replace( /&amp;quot;/g, '"' );
						text = text.replace( /&amp;#39;/g, '"' );
						text = text.replace( /&amp;amp;/g, '&amp;' );
						text = text.replace( /&amp;lt;/g, String.fromCharCode(60) );
						text = text.replace( /&amp;gt;/g, String.fromCharCode(62) );
						return text;
					}

function CopyToClipboard_Copy(text) {
    var flashcopier = 'CopyToClipboard_FlashContainer';
    if(!document.getElementById(flashcopier)) {
        var divholder = document.createElement('div');
        divholder.id = flashcopier;
        document.body.appendChild(divholder);
    }
    document.getElementById(flashcopier).innerHTML = '';
    var divinfo = '&lt;object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ' +
        'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ' +
        'width="0" height="0"&gt;' +
        '&lt;param name="src" value="/_clipboard.swf?clipboard='+encodeURIComponent(text) + '" /&gt;' +
        '&lt;embed src="/_clipboard.swf" FlashVars="clipboard='+encodeURIComponent(text)+'" width="0" height="0" type="application/x-shockwave-flash"&gt;&lt;/embed&gt;' +
        '&lt;/object&gt;'
    document.getElementById(flashcopier).innerHTML = divinfo;
}


					function CopyToClipboard_ViewPlain( text ){
						var win = window.open( '', 'CopyToClipboard_Window', 'width=800, height=600, toolbar=no, menubar=no, scrollbars=auto, resizable=yes, location=no, directories=no, status=no' );
						win.document.write( '&lt;html&gt;&lt;head&gt;&lt;title&gt;Code&lt;/title&gt;&lt;body style="margin:0;padding:0;"&gt;&lt;textarea style="width:100%;height:100%;border:0;"&gt;' + text + '&lt;/textarea&gt;&lt;/body&gt;&lt;/html&gt;' );
					}

                &lt;/script&gt;
            
					&lt;script type="text/javascript"&gt;
						var copyToClipboardeee985c9adfd4b5b9e288ce25d06f1c7_21755 = CopyToClipboard_Strip('USE [master]\r\nGO\r\n/******Object:  StoredProcedure [sys].[sp_MS_replication_installed]******/\r\nSET ANSI_NULLS ON\r\nGO\r\nSET QUOTED_IDENTIFIER ON\r\nGO\r\n \r\n--\r\n-- Name: sp_MS_replication_installed\r\n--\r\n-- Descriptions: \r\n--\r\n-- Parameters: as defined in create statement\r\n--\r\n-- Returns: 0 - success\r\n--          1 - Otherwise\r\n--\r\n-- Security: \r\n-- Requires Certificate signature for catalog access\r\n--\r\nALTER procedure [sys].[sp_MS_replication_installed]\r\nas\r\n    set nocount on\r\n    declare @isinstalled int\r\n    select @isinstalled = 0\r\n    declare @retcode int\r\n    \r\n    EXECUTE @retcode = master.dbo.xp_instance_regread \'HKEY_LOCAL_MACHINE\', \r\n        \'SOFTWARE\\Microsoft\\MSSQLServer\\Replication\',\r\n        \'IsInstalled\',\r\n        @param = @isinstalled OUTPUT\r\n \r\n    IF ( @retcode &amp;lt;&amp;gt; 0 ) or ( @@ERROR &amp;lt;&amp;gt; 0 ) \r\n    begin\r\n        raiserror (21028, 16, -1)\r\n        return (0)\r\n    end\r\n    \r\n    if (@isinstalled is null or @isinstalled = 0)\r\n    begin\r\n        raiserror (21028, 16, -1)\r\n        return (0)\r\n    end\r\n \r\n    return (1)');
					&lt;/script&gt;
&lt;p&gt;I could use the sp_MS_replication_installed stored procedure as is and catch the exception when it got thrown, but I really don&amp;rsquo;t like code that relies on exceptions to operate correctly.&amp;nbsp; Exceptions should be just that &amp;ndash; the exception.&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="border: 1px solid silver; margin: 20px 0px 10px; padding: 4px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 97.5%; font-family: 'Courier New',courier,monospace; direction: ltr; max-height: 350px; font-size: 8pt; cursor: text;"&gt;
&lt;div id="codeSnippet" style="border-style: none; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; replicationInstalled(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; connString) {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum2" style="color: #606060"&gt;   2:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; result = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum3" style="color: #606060"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; (SqlConnection conn = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SqlConnection(connString)) {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum4" style="color: #606060"&gt;   4:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum5" style="color: #606060"&gt;   5:&lt;/span&gt;         conn.Open();&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum6" style="color: #606060"&gt;   6:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; (SqlCommand cmd = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SqlCommand()) {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum7" style="color: #606060"&gt;   7:&lt;/span&gt;             cmd.Connection = conn;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum8" style="color: #606060"&gt;   8:&lt;/span&gt;             cmd.CommandType = CommandType.StoredProcedure;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum9" style="color: #606060"&gt;   9:&lt;/span&gt;             cmd.CommandText = &lt;span style="color: #006080"&gt;"sp_MS_replication_installed"&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum10" style="color: #606060"&gt;  10:&lt;/span&gt;             cmd.Parameters.Add(&lt;span style="color: #006080"&gt;"Result"&lt;/span&gt;, SqlDbType.Int).Direction &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum11" style="color: #606060"&gt;  11:&lt;/span&gt;                 = ParameterDirection.ReturnValue;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum12" style="color: #606060"&gt;  12:&lt;/span&gt;             cmd.ExecuteNonQuery();&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum13" style="color: #606060"&gt;  13:&lt;/span&gt;             result = ((&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)cmd.Parameters[&lt;span style="color: #006080"&gt;"Result"&lt;/span&gt;].Value) == 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum14" style="color: #606060"&gt;  14:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum15" style="color: #606060"&gt;  15:&lt;/span&gt;         conn.Close();&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum16" style="color: #606060"&gt;  16:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum17" style="color: #606060"&gt;  17:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; result;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span id="lnum18" style="color: #606060"&gt;  18:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="CopyToClipboardOuter" &gt;&lt;div class="CopyToClipboardInner"&gt;&lt;a href="javascript:void(0);" title="View Plain" onclick="CopyToClipboard_ViewPlain(copyToClipboardeee985c9adfd4b5b9e288ce25d06f1c7_33054);"&gt;View Plain&lt;/a&gt; &lt;/div&gt;&lt;/div&gt;
					&lt;script type="text/javascript"&gt;
						var copyToClipboardeee985c9adfd4b5b9e288ce25d06f1c7_33054 = CopyToClipboard_Strip('private static bool replicationInstalled(string connString) {\r\n    bool result = false;\r\n    using (SqlConnection conn = new SqlConnection(connString)) {\r\n \r\n        conn.Open();\r\n        using (SqlCommand cmd = new SqlCommand()) {\r\n            cmd.Connection = conn;\r\n            cmd.CommandType = CommandType.StoredProcedure;\r\n            cmd.CommandText = "sp_MS_replication_installed";\r\n            cmd.Parameters.Add("Result", SqlDbType.Int).Direction \r\n                = ParameterDirection.ReturnValue;\r\n            cmd.ExecuteNonQuery();\r\n            result = ((int)cmd.Parameters["Result"].Value) == 0;\r\n        }\r\n        conn.Close();\r\n    }\r\n    return result;\r\n}');
					&lt;/script&gt;
&lt;p&gt;I took a look at the sp_MS_replication_installed stored procedure and found that all it is doing is calling xp_instance_regread and doing error handling. Since I didn&amp;rsquo;t like the error handling that sp_MS_replication_installed was doing, I figured I would call xp_instance_regread myself and do my own error handling.&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="border: 1px solid silver; margin: 20px 0px 10px; padding: 4px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 97.5%; font-family: 'Courier New',courier,monospace; direction: ltr; height: 316px; max-height: 350px; font-size: 8pt; cursor: text;"&gt;
&lt;pre id="codeSnippet" style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 95%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; replicationInstalled(SqlConnection conn) {&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; result = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; (SqlCommand cmd = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SqlCommand()) {&lt;br /&gt;        cmd.Connection = conn;&lt;br /&gt;        cmd.CommandType = CommandType.StoredProcedure;&lt;br /&gt;        cmd.CommandText = &lt;span style="color: #006080"&gt;"xp_instance_regread"&lt;/span&gt;;&lt;br /&gt;        cmd.Parameters.AddWithValue(&lt;span style="color: #006080"&gt;"param1"&lt;/span&gt;, &lt;span style="color: #006080"&gt;"HKEY_LOCAL_MACHINE"&lt;/span&gt;);&lt;br /&gt;        cmd.Parameters.AddWithValue(&lt;span style="color: #006080"&gt;"param2"&lt;/span&gt;, &lt;span style="color: #006080"&gt;"SOFTWARE\\Microsoft\\MSSQLServer\\Replication"&lt;/span&gt;);&lt;br /&gt;        cmd.Parameters.AddWithValue(&lt;span style="color: #006080"&gt;"param3"&lt;/span&gt;, &lt;span style="color: #006080"&gt;"IsInstalled"&lt;/span&gt;);&lt;br /&gt;        cmd.Parameters.AddWithValue(&lt;span style="color: #006080"&gt;"@IsInstalled"&lt;/span&gt;, 0);&lt;br /&gt;        cmd.Parameters[&lt;span style="color: #006080"&gt;"@IsInstalled"&lt;/span&gt;].Direction = ParameterDirection.Output;&lt;br /&gt;        cmd.ExecuteNonQuery();&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; returnValue = cmd.Parameters[&lt;span style="color: #006080"&gt;"@IsInstalled"&lt;/span&gt;].Value;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (returnValue != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; returnValue &lt;span style="color: #0000ff"&gt;is&lt;/span&gt; &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;) {&lt;br /&gt;            result = ((&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)returnValue) == 1;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; result;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="CopyToClipboardOuter" &gt;&lt;div class="CopyToClipboardInner"&gt;&lt;a href="javascript:void(0);" title="View Plain" onclick="CopyToClipboard_ViewPlain(copyToClipboardeee985c9adfd4b5b9e288ce25d06f1c7_36926);"&gt;View Plain&lt;/a&gt; &lt;/div&gt;&lt;/div&gt;
					&lt;script type="text/javascript"&gt;
						var copyToClipboardeee985c9adfd4b5b9e288ce25d06f1c7_36926 = CopyToClipboard_Strip('private static bool replicationInstalled(SqlConnection conn) {    bool result = false;    using (SqlCommand cmd = new SqlCommand()) {        cmd.Connection = conn;        cmd.CommandType = CommandType.StoredProcedure;        cmd.CommandText = "xp_instance_regread";        cmd.Parameters.AddWithValue("param1", "HKEY_LOCAL_MACHINE");        cmd.Parameters.AddWithValue("param2", "SOFTWARE\\\\Microsoft\\\\MSSQLServer\\\\Replication");        cmd.Parameters.AddWithValue("param3", "IsInstalled");        cmd.Parameters.AddWithValue("@IsInstalled", 0);        cmd.Parameters["@IsInstalled"].Direction = ParameterDirection.Output;        cmd.ExecuteNonQuery();        object returnValue = cmd.Parameters["@IsInstalled"].Value;        if (returnValue != null &amp;amp;&amp;amp; returnValue is int) {            result = ((int)returnValue) == 1;        }    }    return result;}');
					&lt;/script&gt;
&lt;p&gt;I changed the replicationInstalled function to call xp_instance_regread directly.&amp;nbsp; If the registry key exists, the @IsInstalled parameter returns the value from the registry.&amp;nbsp; That value tells whether the replication components are installed.&amp;nbsp; If there is no value in the registry, the @IsInstalled parameter returns a null.&amp;nbsp; I take the value of @IsInstalled and check to see if it is null.&amp;nbsp; If it is null, I return false.&amp;nbsp; If it is not null and it is indeed an integer, I return that integer.&lt;/p&gt;
&lt;p&gt;Using the new replicationInstalled function my program is able to quickly check if the replication components are installed before attempting to do any synchronization and without throwing any exceptions.&amp;nbsp; Mission accomplished!&lt;/p&gt;</description>
      <link>http://www.dogspots.com/DSBE/post/2009/10/02/AreReplicationComponentsInstalled.aspx</link>
      <author>Bill</author>
      <comments>http://www.dogspots.com/DSBE/post/2009/10/02/AreReplicationComponentsInstalled.aspx#comment</comments>
      <guid>http://www.dogspots.com/DSBE/post.aspx?id=b28f6f4e-c0aa-4d86-9f25-9ebe34639402</guid>
      <pubDate>Fri, 02 Oct 2009 23:16:00 -0500</pubDate>
      <category>.Net Programming</category>
      <dc:publisher>Bill</dc:publisher>
      <pingback:server>http://www.dogspots.com/DSBE/pingback.axd</pingback:server>
      <pingback:target>http://www.dogspots.com/DSBE/post.aspx?id=b28f6f4e-c0aa-4d86-9f25-9ebe34639402</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.dogspots.com/DSBE/trackback.axd?id=b28f6f4e-c0aa-4d86-9f25-9ebe34639402</trackback:ping>
      <wfw:comment>http://www.dogspots.com/DSBE/post/2009/10/02/AreReplicationComponentsInstalled.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.dogspots.com/DSBE/syndication.axd?post=b28f6f4e-c0aa-4d86-9f25-9ebe34639402</wfw:commentRss>
    </item>
    <item>
      <title>Presenting Detail Values as Part of the Master – part 3</title>
      <description>&lt;p&gt;&lt;em&gt;This is part three of a three part series on working with master-detail data.&amp;#160; In &lt;/em&gt;&lt;a title="DogSpots" href="http://www.dogspots.com/DSBE/post.aspx?id=cae58dc2-be59-47cc-b096-feacfdcf3948"&gt;part one&lt;/a&gt;&lt;em&gt;&lt;/em&gt;&lt;em&gt; I showed how to present detail values on the master using a utility I wrote called the SubPropertyAccessor. &lt;em&gt;In &lt;a title="DogSpots" href="http://www.dogspots.com/DSBE/post.aspx?id=3826c767-a96f-4e92-886b-c5c2ebe94a05"&gt;part two&lt;/a&gt; I showed how the SubPropertyAccessor works. In this part, I introduce a descendant of DataGridViewColumn that will allow us to show the indexed detail data in line with the master data as additional columns.&amp;#160; I also introduce a descendent of TypeDescriptionProvider that allows the DataGridView to see the SubProperty as a proper property so that the rest of the grid functionality will still work.&lt;/em&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Note: The SubPropertyAccessor was called SubAttributeAccessor in parts one and two.&lt;/em&gt;&lt;/p&gt;  &lt;h2&gt;SubPropertyColumn&lt;/h2&gt;  &lt;p&gt;The whole point of having detail values appear as part of a master record is to show the data in a grid where the detail values would appear in columns next to the other properties in the record.&amp;#160; In order to do this I created a descendant of DataGridViewColumn called SubPropertyColumn.&amp;#160; Actually, SubPropertyColumn is a descendant of DataGridViewTextBoxColumn.&amp;#160; The DataGridViewTextBoxColumn has most of the functionality I want.&amp;#160; I only need to have the data marshaled in and out of the data bound item in a specific way.&lt;/p&gt;  &lt;p&gt;The first thing we need is to know where the SubPropertyAccessor is on the data bound item.&amp;#160; This will be a property on the column that can be set at design time in the DataGridView designer.&lt;/p&gt;  &lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: visible; border-left: silver 1px solid; width: 97.54%; cursor: text; direction: ltr; max-height: 1000px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; height: 222px; background-color: #f4f4f4; text-align: left"&gt;   &lt;div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;     &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum72" style="color: #606060"&gt;  72:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum73" style="color: #606060"&gt;  73:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// The name of the property that is the indexed property.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum74" style="color: #606060"&gt;  74:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// Note that for sorting to work this&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum75" style="color: #606060"&gt;  75:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// should be set to 'Properties'&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum76" style="color: #606060"&gt;  76:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum77" style="color: #606060"&gt;  77:&lt;/span&gt;         [Category(&lt;span style="color: #006080"&gt;&amp;quot;Data&amp;quot;&lt;/span&gt;),&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum78" style="color: #606060"&gt;  78:&lt;/span&gt;         DefaultValue(&lt;span style="color: #006080"&gt;&amp;quot;Properties&amp;quot;&lt;/span&gt;),&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum79" style="color: #606060"&gt;  79:&lt;/span&gt;         Description(&lt;span style="color: #006080"&gt;&amp;quot;The name of the property that is the indexed property.&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum80" style="color: #606060"&gt;  80:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; IndexedPropertyName {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum81" style="color: #606060"&gt;  81:&lt;/span&gt;             get { &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; fIndexedPropertyName; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum82" style="color: #606060"&gt;  82:&lt;/span&gt;             set {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum83" style="color: #606060"&gt;  83:&lt;/span&gt;                 fIndexedPropertyName = &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum84" style="color: #606060"&gt;  84:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum85" style="color: #606060"&gt;  85:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="CopyToClipboardOuter" &gt;&lt;div class="CopyToClipboardInner"&gt;&lt;a href="javascript:void(0);" title="View Plain" onclick="CopyToClipboard_ViewPlain(copyToClipboard200319f66a954592b09711aa4f568d73_10448);"&gt;View Plain&lt;/a&gt; &lt;/div&gt;&lt;/div&gt;
					&lt;script type="text/javascript"&gt;
						var copyToClipboard200319f66a954592b09711aa4f568d73_10448 = CopyToClipboard_Strip('        /// &amp;lt;summary&amp;gt;\r\n        /// The name of the property that is the indexed property.\r\n        /// Note that for sorting to work this\r\n        /// should be set to \'Properties\'\r\n        /// &amp;lt;/summary&amp;gt;\r\n        [Category(&amp;quot;Data&amp;quot;),\r\n        DefaultValue(&amp;quot;Properties&amp;quot;),\r\n        Description(&amp;quot;The name of the property that is the indexed property.&amp;quot;)]\r\n        public string IndexedPropertyName {\r\n            get { return fIndexedPropertyName; }\r\n            set {\r\n                fIndexedPropertyName = value;\r\n            }\r\n        }');
					&lt;/script&gt;

&lt;p&gt;Now that we know where to find the SubPropertyAccessor, we need to know which property we are looking for.&amp;#160; This is the index that we will pass into the SubPropertyAccessor.&amp;#160; We need another string property.&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: hidden; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 1000px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; height: 224px; background-color: #f4f4f4; text-align: left"&gt;
  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum114" style="color: #606060"&gt; 114:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum115" style="color: #606060"&gt; 115:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// The index to pass to the indexed property to get the value for this column.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum116" style="color: #606060"&gt; 116:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum117" style="color: #606060"&gt; 117:&lt;/span&gt;         [Category(&lt;span style="color: #006080"&gt;&amp;quot;Data&amp;quot;&lt;/span&gt;),&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum118" style="color: #606060"&gt; 118:&lt;/span&gt;         DefaultValue(&lt;span style="color: #006080"&gt;&amp;quot;&amp;quot;&lt;/span&gt;),&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum119" style="color: #606060"&gt; 119:&lt;/span&gt;         Description(&lt;span style="color: #006080"&gt;&amp;quot;The index to pass to the indexed property to get the value for this column.&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum120" style="color: #606060"&gt; 120:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; PropertyIndex {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum121" style="color: #606060"&gt; 121:&lt;/span&gt;             get {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum122" style="color: #606060"&gt; 122:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.DataPropertyName;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum123" style="color: #606060"&gt; 123:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum124" style="color: #606060"&gt; 124:&lt;/span&gt;             set {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum125" style="color: #606060"&gt; 125:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.DataPropertyName = &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum126" style="color: #606060"&gt; 126:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum127" style="color: #606060"&gt; 127:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;div class="CopyToClipboardOuter" &gt;&lt;div class="CopyToClipboardInner"&gt;&lt;a href="javascript:void(0);" title="View Plain" onclick="CopyToClipboard_ViewPlain(copyToClipboard200319f66a954592b09711aa4f568d73_19870);"&gt;View Plain&lt;/a&gt; &lt;/div&gt;&lt;/div&gt;
					&lt;script type="text/javascript"&gt;
						var copyToClipboard200319f66a954592b09711aa4f568d73_19870 = CopyToClipboard_Strip('        /// &amp;lt;summary&amp;gt;\r\n        /// The index to pass to the indexed property to get the value for this column.\r\n        /// &amp;lt;/summary&amp;gt;\r\n        [Category(&amp;quot;Data&amp;quot;),\r\n        DefaultValue(&amp;quot;&amp;quot;),\r\n        Description(&amp;quot;The index to pass to the indexed property to get the value for this column.&amp;quot;)]\r\n        public string PropertyIndex {\r\n            get {\r\n                return base.DataPropertyName;\r\n            }\r\n            set {\r\n                base.DataPropertyName = value;\r\n            }\r\n        }');
					&lt;/script&gt;

&lt;p&gt;This property doesn’t have any backing data of its own.&amp;#160; It is using the DataPropertyName of the base DataGridViewTextBoxColumn.&amp;#160; We do this because the base DataGridColumn bases a lot of functionality on the DataPropertyName property.&amp;#160; For example, if this property is blank the base DataGridColumn doesn’t consider the column to be a data bound column.&amp;#160; If we are going to make use of the functionality provided by the base classes, we going to have to make them happy.&amp;#160; This may seem like a &lt;a title="Wikipedia" href="http://en.wikipedia.org/wiki/Kludge" target="_blank"&gt;kludge&lt;/a&gt;, but it’s better than having to reinvent the DataGridColumn.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Since we’re re-purposing the DataPropertyName property, let’s go ahead and hide it from the designer so it’s not confusing.&lt;/p&gt;

&lt;h1&gt;&lt;/h1&gt;

&lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: hidden; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 1000px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4; text-align: left"&gt;
  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum57" style="color: #606060"&gt;  57:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum58" style="color: #606060"&gt;  58:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// We're calling this property PropertyIndex instead, so we'll hide this from the Property Viewer.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum59" style="color: #606060"&gt;  59:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum60" style="color: #606060"&gt;  60:&lt;/span&gt;         [EditorBrowsable(EditorBrowsableState.Never),&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum61" style="color: #606060"&gt;  61:&lt;/span&gt;         Browsable(&lt;span style="color: #0000ff"&gt;false&lt;/span&gt;),&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum62" style="color: #606060"&gt;  62:&lt;/span&gt;         DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Obsolete(&lt;span style="color: #006080"&gt;&amp;quot;Use PropertyIndex instead&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum63" style="color: #606060"&gt;  63:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; DataPropertyName {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum64" style="color: #606060"&gt;  64:&lt;/span&gt;             get {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum65" style="color: #606060"&gt;  65:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.DataPropertyName;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum66" style="color: #606060"&gt;  66:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum67" style="color: #606060"&gt;  67:&lt;/span&gt;             set {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum68" style="color: #606060"&gt;  68:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.DataPropertyName = &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum69" style="color: #606060"&gt;  69:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum70" style="color: #606060"&gt;  70:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;div class="CopyToClipboardOuter" &gt;&lt;div class="CopyToClipboardInner"&gt;&lt;a href="javascript:void(0);" title="View Plain" onclick="CopyToClipboard_ViewPlain(copyToClipboard200319f66a954592b09711aa4f568d73_29899);"&gt;View Plain&lt;/a&gt; &lt;/div&gt;&lt;/div&gt;
					&lt;script type="text/javascript"&gt;
						var copyToClipboard200319f66a954592b09711aa4f568d73_29899 = CopyToClipboard_Strip('        /// &amp;lt;summary&amp;gt;\r\n        /// We\'re calling this property PropertyIndex instead, so we\'ll hide this from the Property Viewer.\r\n        /// &amp;lt;/summary&amp;gt;\r\n        [EditorBrowsable(EditorBrowsableState.Never),\r\n        Browsable(false),\r\n        DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Obsolete(&amp;quot;Use PropertyIndex instead&amp;quot;)]\r\n        new public string DataPropertyName {\r\n            get {\r\n                return base.DataPropertyName;\r\n            }\r\n            set {\r\n                base.DataPropertyName = value;\r\n            }\r\n        }');
					&lt;/script&gt;

&lt;p&gt;There’s one more piece if information that will make things much easier.&amp;#160; That is the type of the data that will be shown in the column.&amp;#160; Since the property from where we are getting the doesn’t really exist, we’ll make a property here and set it at design time.&lt;/p&gt;

&lt;h1&gt;&lt;/h1&gt;

&lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: hidden; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 1000px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4; text-align: left"&gt;
  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum143" style="color: #606060"&gt; 143:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum144" style="color: #606060"&gt; 144:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// Specifies the type of the value that is contained in the data.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum145" style="color: #606060"&gt; 145:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// In order to allow the ValueType property to be set in the Visual Studio designer&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum146" style="color: #606060"&gt; 146:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// This property is hidden and presented as a string.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum147" style="color: #606060"&gt; 147:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum148" style="color: #606060"&gt; 148:&lt;/span&gt;         [Category(&lt;span style="color: #006080"&gt;&amp;quot;Data&amp;quot;&lt;/span&gt;),&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum149" style="color: #606060"&gt; 149:&lt;/span&gt;         DefaultValue(&lt;span style="color: #006080"&gt;&amp;quot;System.String&amp;quot;&lt;/span&gt;),&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum150" style="color: #606060"&gt; 150:&lt;/span&gt;         Description(&lt;span style="color: #006080"&gt;&amp;quot;Specifies the type of the value that is contained in the data.&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum151" style="color: #606060"&gt; 151:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; ValueType {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum152" style="color: #606060"&gt; 152:&lt;/span&gt;             get { &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; fValueTypeString; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum153" style="color: #606060"&gt; 153:&lt;/span&gt;             set {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum154" style="color: #606060"&gt; 154:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (fValueTypeString != &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum155" style="color: #606060"&gt; 155:&lt;/span&gt;                     fValueTypeString = &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum156" style="color: #606060"&gt; 156:&lt;/span&gt;                     fValueType = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum157" style="color: #606060"&gt; 157:&lt;/span&gt;                 }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum158" style="color: #606060"&gt; 158:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum159" style="color: #606060"&gt; 159:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;div class="CopyToClipboardOuter" &gt;&lt;div class="CopyToClipboardInner"&gt;&lt;a href="javascript:void(0);" title="View Plain" onclick="CopyToClipboard_ViewPlain(copyToClipboard200319f66a954592b09711aa4f568d73_41196);"&gt;View Plain&lt;/a&gt; &lt;/div&gt;&lt;/div&gt;
					&lt;script type="text/javascript"&gt;
						var copyToClipboard200319f66a954592b09711aa4f568d73_41196 = CopyToClipboard_Strip('        /// &amp;lt;summary&amp;gt;\r\n        /// Specifies the type of the value that is contained in the data.\r\n        /// In order to allow the ValueType property to be set in the Visual Studio designer\r\n        /// This property is hidden and presented as a string.\r\n        /// &amp;lt;/summary&amp;gt;\r\n        [Category(&amp;quot;Data&amp;quot;),\r\n        DefaultValue(&amp;quot;System.String&amp;quot;),\r\n        Description(&amp;quot;Specifies the type of the value that is contained in the data.&amp;quot;)]\r\n        new public string ValueType {\r\n            get { return fValueTypeString; }\r\n            set {\r\n                if (fValueTypeString != value) {\r\n                    fValueTypeString = value;\r\n                    fValueType = null;\r\n                }\r\n            }\r\n        }');
					&lt;/script&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;I named the property ValueType even though there already is a ValueType property on the base class.&amp;#160; I hide that property and replace it with this string property.&amp;#160; I made this a string property to avoid having to make a property designer that offered a list of types.&amp;#160; This does put a burden on the user to type in the name of an actual type.&amp;#160; The property designer would be an obvious improvement.&lt;/p&gt;

&lt;p&gt;I also added an internal property called InternalValueType that converts the string representation of the type to an actual Type.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: hidden; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 1000px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4; text-align: left"&gt;
  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum87" style="color: #606060"&gt;  87:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum88" style="color: #606060"&gt;  88:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// In order to avoid having to make a property designer for the Type type&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum89" style="color: #606060"&gt;  89:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// The ValueType property is presented as a string which is easily manipulated&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum90" style="color: #606060"&gt;  90:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// in the Visual Studio Properties Window.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum91" style="color: #606060"&gt;  91:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum92" style="color: #606060"&gt;  92:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;internal&lt;/span&gt; Type InternalValueType {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum93" style="color: #606060"&gt;  93:&lt;/span&gt;             get {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum94" style="color: #606060"&gt;  94:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum95" style="color: #606060"&gt;  95:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (fValueType == &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum96" style="color: #606060"&gt;  96:&lt;/span&gt;                     fValueType = GetType(&lt;span style="color: #006080"&gt;&amp;quot;&amp;quot;&lt;/span&gt;, fValueTypeString);&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum97" style="color: #606060"&gt;  97:&lt;/span&gt;                 }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum98" style="color: #606060"&gt;  98:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum99" style="color: #606060"&gt;  99:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; fValueType;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum100" style="color: #606060"&gt; 100:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum101" style="color: #606060"&gt; 101:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;div class="CopyToClipboardOuter" &gt;&lt;div class="CopyToClipboardInner"&gt;&lt;a href="javascript:void(0);" title="View Plain" onclick="CopyToClipboard_ViewPlain(copyToClipboard200319f66a954592b09711aa4f568d73_51576);"&gt;View Plain&lt;/a&gt; &lt;/div&gt;&lt;/div&gt;
					&lt;script type="text/javascript"&gt;
						var copyToClipboard200319f66a954592b09711aa4f568d73_51576 = CopyToClipboard_Strip('        /// &amp;lt;summary&amp;gt;\r\n        /// In order to avoid having to make a property designer for the Type type\r\n        /// The ValueType property is presented as a string which is easily manipulated\r\n        /// in the Visual Studio Properties Window.\r\n        /// &amp;lt;/summary&amp;gt;\r\n        internal Type InternalValueType {\r\n            get {\r\n\r\n                if (fValueType == null) {\r\n                    fValueType = GetType(&amp;quot;&amp;quot;, fValueTypeString);\r\n                }\r\n\r\n                return fValueType;\r\n            }\r\n        }');
					&lt;/script&gt;

&lt;p&gt;The actual work of converting the string into a Type is done in a method called GetType which can be seen in the attached source code.&lt;/p&gt;

&lt;h2&gt;&amp;#160;&lt;/h2&gt;

&lt;h2&gt;SubPropertyCell&lt;/h2&gt;

&lt;p&gt;The rest of the work of marshaling the data in and out of the SubPropertyAccessor is done at the cell level in a class called SubPropertyCell.&amp;#160; SubPropertyCell is derived from DataGridViewTextBoxCell and gets most of its functionality from there.&amp;#160; There are four methods that do all of the work, GetValue, SetValue, GetFormatedValue and ParseFormattedValue.&amp;#160; They are all overrides of methods on the base DataGridViewCell.&amp;#160; An extra method, getAccessor contains some code that is shared by GetValue and SetValue.&lt;/p&gt;

&lt;h3&gt;GetValue&lt;/h3&gt;

&lt;p&gt;The GetValue method is called by the DataGridView when it needs to get a value from the underlying bound data.&amp;#160; The GetValue method uses the information set in the Column to get a value out of the SubPropertyAccessor.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: hidden; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 1000px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4; text-align: left"&gt;
  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum131" style="color: #606060"&gt; 131:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum132" style="color: #606060"&gt; 132:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// Gets the value of the cell.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum133" style="color: #606060"&gt; 133:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum134" style="color: #606060"&gt; 134:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;rowIndex&amp;quot;&amp;gt;The index of the cell's parent row.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum135" style="color: #606060"&gt; 135:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;returns&amp;gt;The value contained in the cell.&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum136" style="color: #606060"&gt; 136:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;remarks&amp;gt;It is here that the SubPropertyAccessor is used to get the correct value stored in the sub property.&amp;lt;/remarks&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum137" style="color: #606060"&gt; 137:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; GetValue(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; rowIndex) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum138" style="color: #606060"&gt; 138:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; result = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum139" style="color: #606060"&gt; 139:&lt;/span&gt;             SubPropertyColumn column = (DataGridView.Columns[ColumnIndex] &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; SubPropertyColumn);&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum140" style="color: #606060"&gt; 140:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum141" style="color: #606060"&gt; 141:&lt;/span&gt;             &lt;span style="color: #008000"&gt;//Get the SubPropertyAccessor and the PropertyInfo for the property &lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum142" style="color: #606060"&gt; 142:&lt;/span&gt;             &lt;span style="color: #008000"&gt;//on it that has the data needed&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum143" style="color: #606060"&gt; 143:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; accessorObject;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum144" style="color: #606060"&gt; 144:&lt;/span&gt;             PropertyInfo indexedPropertyInfo;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum145" style="color: #606060"&gt; 145:&lt;/span&gt;             getAccessor(rowIndex, &lt;span style="color: #0000ff"&gt;out&lt;/span&gt; accessorObject, &lt;span style="color: #0000ff"&gt;out&lt;/span&gt; indexedPropertyInfo);&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum146" style="color: #606060"&gt; 146:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum147" style="color: #606060"&gt; 147:&lt;/span&gt;             &lt;span style="color: #008000"&gt;//use some reflection to get the value out of the &lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum148" style="color: #606060"&gt; 148:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (indexedPropertyInfo != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum149" style="color: #606060"&gt; 149:&lt;/span&gt;                 result = indexedPropertyInfo.GetValue(accessorObject, &lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum150" style="color: #606060"&gt; 150:&lt;/span&gt;                     &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #0000ff"&gt;object&lt;/span&gt;[] { column.PropertyIndex });&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum151" style="color: #606060"&gt; 151:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum152" style="color: #606060"&gt; 152:&lt;/span&gt;             &lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum153" style="color: #606060"&gt; 153:&lt;/span&gt;            &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; result ?? (column != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt; ? column.NullValue : &lt;span style="color: #006080"&gt;&amp;quot;&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum154" style="color: #606060"&gt; 154:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;div class="CopyToClipboardOuter" &gt;&lt;div class="CopyToClipboardInner"&gt;&lt;a href="javascript:void(0);" title="View Plain" onclick="CopyToClipboard_ViewPlain(copyToClipboard200319f66a954592b09711aa4f568d73_67773);"&gt;View Plain&lt;/a&gt; &lt;/div&gt;&lt;/div&gt;
					&lt;script type="text/javascript"&gt;
						var copyToClipboard200319f66a954592b09711aa4f568d73_67773 = CopyToClipboard_Strip('        /// &amp;lt;summary&amp;gt;\r\n        /// Gets the value of the cell.\r\n        /// &amp;lt;/summary&amp;gt;\r\n        /// &amp;lt;param name=&amp;quot;rowIndex&amp;quot;&amp;gt;The index of the cell\'s parent row.&amp;lt;/param&amp;gt;\r\n        /// &amp;lt;returns&amp;gt;The value contained in the cell.&amp;lt;/returns&amp;gt;\r\n        /// &amp;lt;remarks&amp;gt;It is here that the SubPropertyAccessor is used to get the correct value stored in the sub property.&amp;lt;/remarks&amp;gt;\r\n        protected override object GetValue(int rowIndex) {\r\n            object result = null;\r\n            SubPropertyColumn column = (DataGridView.Columns[ColumnIndex] as SubPropertyColumn);\r\n\r\n            //Get the SubPropertyAccessor and the PropertyInfo for the property \r\n            //on it that has the data needed\r\n            object accessorObject;\r\n            PropertyInfo indexedPropertyInfo;\r\n            getAccessor(rowIndex, out accessorObject, out indexedPropertyInfo);\r\n\r\n            //use some reflection to get the value out of the \r\n            if (indexedPropertyInfo != null) {\r\n                result = indexedPropertyInfo.GetValue(accessorObject, \r\n                    new object[] { column.PropertyIndex });\r\n            }\r\n            \r\n           return result ?? (column != null ? column.NullValue : &amp;quot;&amp;quot;);\r\n        }');
					&lt;/script&gt;

&lt;p&gt;The GetValue method first finds the accessor object and gets a PropertyInfo for the property that contains the sub-property data using the getAccessor method.&amp;#160; It then uses reflection to get the value out of the accessor object.&lt;/p&gt;

&lt;p&gt;The getAccessor method doesn’t look specifically for a SubPropertyAccessor.&amp;#160; As long IndexedPropertyName on the subPropertyColumn points to a property that is an object that has a default indexed property that takes a single string parameter as an index it will work.&amp;#160; In fact, if the IndexedPropertyName is blank and the data bound object itself has a default indexed property that takes a single string parameter, it will still work.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 1000px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4; text-align: left"&gt;
  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum73" style="color: #606060"&gt;  73:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum74" style="color: #606060"&gt;  74:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// Get the object that contains the sub-property data as well as a &lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum75" style="color: #606060"&gt;  75:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// Property info for the indexed property on that object.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum76" style="color: #606060"&gt;  76:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum77" style="color: #606060"&gt;  77:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;rowIndex&amp;quot;&amp;gt;The index of the row in the grid from which to get the DataBoundObject. &amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum78" style="color: #606060"&gt;  78:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;accessorObject&amp;quot;&amp;gt;The object that contains the sub-property data is returned here.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum79" style="color: #606060"&gt;  79:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;indexedPropertyInfo&amp;quot;&amp;gt;The PropertyInfo for the property on the accessor object that is the indexed property that contains the sub-property data&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum80" style="color: #606060"&gt;  80:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; getAccessor(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; rowIndex, &lt;span style="color: #0000ff"&gt;out&lt;/span&gt; &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; accessorObject, &lt;span style="color: #0000ff"&gt;out&lt;/span&gt; PropertyInfo indexedPropertyInfo) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum81" style="color: #606060"&gt;  81:&lt;/span&gt;             &lt;span style="color: #008000"&gt;//Set up some local variables to access the row, column and data bound item.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum82" style="color: #606060"&gt;  82:&lt;/span&gt;             DataGridViewRow row = DataGridView.Rows[rowIndex];&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum83" style="color: #606060"&gt;  83:&lt;/span&gt;             Object rowItem = row.DataBoundItem;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum84" style="color: #606060"&gt;  84:&lt;/span&gt;             SubPropertyColumn subPropertyColumn = DataGridView.Columns[ColumnIndex] &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; SubPropertyColumn;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum85" style="color: #606060"&gt;  85:&lt;/span&gt;             accessorObject = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum86" style="color: #606060"&gt;  86:&lt;/span&gt;             indexedPropertyInfo = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum87" style="color: #606060"&gt;  87:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (rowItem != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum88" style="color: #606060"&gt;  88:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (subPropertyColumn != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum89" style="color: #606060"&gt;  89:&lt;/span&gt;                     &lt;span style="color: #008000"&gt;//It is possible that the DataBoundItem is actually the SubPropertyAccessor&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum90" style="color: #606060"&gt;  90:&lt;/span&gt;                     &lt;span style="color: #008000"&gt;//so we assume that is the case&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum91" style="color: #606060"&gt;  91:&lt;/span&gt;                     accessorObject = rowItem;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum92" style="color: #606060"&gt;  92:&lt;/span&gt;                     Type accessorType = accessorObject.GetType();&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum93" style="color: #606060"&gt;  93:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum94" style="color: #606060"&gt;  94:&lt;/span&gt;                     &lt;span style="color: #008000"&gt;//It is more likely that the SubPropertyAccessor is contained by the DataBoundItem&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum95" style="color: #606060"&gt;  95:&lt;/span&gt;                     &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (!&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;.IsNullOrEmpty(subPropertyColumn.IndexedPropertyName)) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum96" style="color: #606060"&gt;  96:&lt;/span&gt;                         &lt;span style="color: #008000"&gt;//get a PropertyInfo for the IndexedProperty&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum97" style="color: #606060"&gt;  97:&lt;/span&gt;                         indexedPropertyInfo = accessorType.GetProperty(subPropertyColumn.IndexedPropertyName);&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum98" style="color: #606060"&gt;  98:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum99" style="color: #606060"&gt;  99:&lt;/span&gt;                         accessorObject = indexedPropertyInfo.GetValue(rowItem, &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum100" style="color: #606060"&gt; 100:&lt;/span&gt;                         accessorType = accessorObject.GetType();&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum101" style="color: #606060"&gt; 101:&lt;/span&gt;                     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum102" style="color: #606060"&gt; 102:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum103" style="color: #606060"&gt; 103:&lt;/span&gt;                     &lt;span style="color: #008000"&gt;//Find the indexed property that is a default property and takes a single string as the index&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum104" style="color: #606060"&gt; 104:&lt;/span&gt;                     MemberInfo[] members = accessorType.GetDefaultMembers();&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum105" style="color: #606060"&gt; 105:&lt;/span&gt;                     &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (members.Length &amp;gt; 0) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum106" style="color: #606060"&gt; 106:&lt;/span&gt;                         &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; memberNdx = 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum107" style="color: #606060"&gt; 107:&lt;/span&gt;                         indexedPropertyInfo = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum108" style="color: #606060"&gt; 108:&lt;/span&gt;                         &lt;span style="color: #008000"&gt;//check each of the members.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum109" style="color: #606060"&gt; 109:&lt;/span&gt;                         &lt;span style="color: #0000ff"&gt;while&lt;/span&gt; (memberNdx &amp;lt; members.Length &amp;amp;&amp;amp; indexedPropertyInfo == &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum110" style="color: #606060"&gt; 110:&lt;/span&gt;                             &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (members[memberNdx].MemberType == MemberTypes.Property) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum111" style="color: #606060"&gt; 111:&lt;/span&gt;                                 PropertyInfo propertyinfo = accessorType.GetProperty(members[memberNdx].Name);&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum112" style="color: #606060"&gt; 112:&lt;/span&gt;                                 ParameterInfo[] indexedParameters = propertyinfo.GetIndexParameters();&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum113" style="color: #606060"&gt; 113:&lt;/span&gt;                                 &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (indexedParameters.Length == 1) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum114" style="color: #606060"&gt; 114:&lt;/span&gt;                                     &lt;span style="color: #008000"&gt;//The member is a property, it has indexed parameters,&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum115" style="color: #606060"&gt; 115:&lt;/span&gt;                                     &lt;span style="color: #008000"&gt;//it has only one indexed parameter and that&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum116" style="color: #606060"&gt; 116:&lt;/span&gt;                                     &lt;span style="color: #008000"&gt;//one indexed parameter is of type string&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum117" style="color: #606060"&gt; 117:&lt;/span&gt;                                     &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (indexedParameters[0].ParameterType == &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;)) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum118" style="color: #606060"&gt; 118:&lt;/span&gt;                                         indexedPropertyInfo = accessorType.GetProperty(members[memberNdx].Name);&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum119" style="color: #606060"&gt; 119:&lt;/span&gt;                                     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum120" style="color: #606060"&gt; 120:&lt;/span&gt;                                 }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum121" style="color: #606060"&gt; 121:&lt;/span&gt;                             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum122" style="color: #606060"&gt; 122:&lt;/span&gt;                             memberNdx++;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum123" style="color: #606060"&gt; 123:&lt;/span&gt;                         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum124" style="color: #606060"&gt; 124:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum125" style="color: #606060"&gt; 125:&lt;/span&gt;                     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum126" style="color: #606060"&gt; 126:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum127" style="color: #606060"&gt; 127:&lt;/span&gt;                 }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum128" style="color: #606060"&gt; 128:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum129" style="color: #606060"&gt; 129:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;div class="CopyToClipboardOuter" &gt;&lt;div class="CopyToClipboardInner"&gt;&lt;a href="javascript:void(0);" title="View Plain" onclick="CopyToClipboard_ViewPlain(copyToClipboard200319f66a954592b09711aa4f568d73_103274);"&gt;View Plain&lt;/a&gt; &lt;/div&gt;&lt;/div&gt;
					&lt;script type="text/javascript"&gt;
						var copyToClipboard200319f66a954592b09711aa4f568d73_103274 = CopyToClipboard_Strip('        /// &amp;lt;summary&amp;gt;\r\n        /// Get the object that contains the sub-property data as well as a \r\n        /// Property info for the indexed property on that object.\r\n        /// &amp;lt;/summary&amp;gt;\r\n        /// &amp;lt;param name=&amp;quot;rowIndex&amp;quot;&amp;gt;The index of the row in the grid from which to get the DataBoundObject. &amp;lt;/param&amp;gt;\r\n        /// &amp;lt;param name=&amp;quot;accessorObject&amp;quot;&amp;gt;The object that contains the sub-property data is returned here.&amp;lt;/param&amp;gt;\r\n        /// &amp;lt;param name=&amp;quot;indexedPropertyInfo&amp;quot;&amp;gt;The PropertyInfo for the property on the accessor object that is the indexed property that contains the sub-property data&amp;lt;/param&amp;gt;\r\n        private void getAccessor(int rowIndex, out object accessorObject, out PropertyInfo indexedPropertyInfo) {\r\n            //Set up some local variables to access the row, column and data bound item.\r\n            DataGridViewRow row = DataGridView.Rows[rowIndex];\r\n            Object rowItem = row.DataBoundItem;\r\n            SubPropertyColumn subPropertyColumn = DataGridView.Columns[ColumnIndex] as SubPropertyColumn;\r\n            accessorObject = null;\r\n            indexedPropertyInfo = null;\r\n            if (rowItem != null) {\r\n                if (subPropertyColumn != null) {\r\n                    //It is possible that the DataBoundItem is actually the SubPropertyAccessor\r\n                    //so we assume that is the case\r\n                    accessorObject = rowItem;\r\n                    Type accessorType = accessorObject.GetType();\r\n\r\n                    //It is more likely that the SubPropertyAccessor is contained by the DataBoundItem\r\n                    if (!string.IsNullOrEmpty(subPropertyColumn.IndexedPropertyName)) {\r\n                        //get a PropertyInfo for the IndexedProperty\r\n                        indexedPropertyInfo = accessorType.GetProperty(subPropertyColumn.IndexedPropertyName);\r\n\r\n                        accessorObject = indexedPropertyInfo.GetValue(rowItem, null);\r\n                        accessorType = accessorObject.GetType();\r\n                    }\r\n\r\n                    //Find the indexed property that is a default property and takes a single string as the index\r\n                    MemberInfo[] members = accessorType.GetDefaultMembers();\r\n                    if (members.Length &amp;gt; 0) {\r\n                        int memberNdx = 0;\r\n                        indexedPropertyInfo = null;\r\n                        //check each of the members.\r\n                        while (memberNdx &amp;lt; members.Length &amp;amp;&amp;amp; indexedPropertyInfo == null) {\r\n                            if (members[memberNdx].MemberType == MemberTypes.Property) {\r\n                                PropertyInfo propertyinfo = accessorType.GetProperty(members[memberNdx].Name);\r\n                                ParameterInfo[] indexedParameters = propertyinfo.GetIndexParameters();\r\n                                if (indexedParameters.Length == 1) {\r\n                                    //The member is a property, it has indexed parameters,\r\n                                    //it has only one indexed parameter and that\r\n                                    //one indexed parameter is of type string\r\n                                    if (indexedParameters[0].ParameterType == typeof(string)) {\r\n                                        indexedPropertyInfo = accessorType.GetProperty(members[memberNdx].Name);\r\n                                    }\r\n                                }\r\n                            }\r\n                            memberNdx++;\r\n                        }\r\n\r\n                    }\r\n\r\n                }\r\n            }\r\n        }');
					&lt;/script&gt;

&lt;h3&gt;&amp;#160;&lt;/h3&gt;

&lt;h3&gt;SetValue&lt;/h3&gt;

&lt;p&gt;The DataGridView uses the SetValue method when it needs to put a value into the underlying bound data.&amp;#160; The SetValue method uses essentially the same code as GetValue to put the data into the sub-property.&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: hidden; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 1000px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4; text-align: left"&gt;
  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum156" style="color: #606060"&gt; 156:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum157" style="color: #606060"&gt; 157:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// Changes the value of a cell&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum158" style="color: #606060"&gt; 158:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum159" style="color: #606060"&gt; 159:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;rowIndex&amp;quot;&amp;gt;The index of the cell's parent row.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum160" style="color: #606060"&gt; 160:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;value&amp;quot;&amp;gt;The new value of the cell&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum161" style="color: #606060"&gt; 161:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;returns&amp;gt;A boolean that tells if the value was successfully changed in the underlying data.&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum162" style="color: #606060"&gt; 162:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;remarks&amp;gt;It is here that the SubPropertyAccessor is used to put the correct value into the sub property.&amp;lt;/remarks&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum163" style="color: #606060"&gt; 163:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; SetValue(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; rowIndex, &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum164" style="color: #606060"&gt; 164:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (DataGridView == &lt;span style="color: #0000ff"&gt;null&lt;/span&gt; || DataGridView.RowCount &amp;lt;= 0) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum165" style="color: #606060"&gt; 165:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.SetValue(rowIndex, &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum166" style="color: #606060"&gt; 166:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum167" style="color: #606060"&gt; 167:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum168" style="color: #606060"&gt; 168:&lt;/span&gt;             &lt;span style="color: #008000"&gt;//Get the SubPropertyAccessor and the PropertyInfo for the property &lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum169" style="color: #606060"&gt; 169:&lt;/span&gt;             &lt;span style="color: #008000"&gt;//on it that has the data needed&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum170" style="color: #606060"&gt; 170:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; accessorObject;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum171" style="color: #606060"&gt; 171:&lt;/span&gt;             PropertyInfo indexedPropertyInfo;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum172" style="color: #606060"&gt; 172:&lt;/span&gt;             getAccessor(rowIndex, &lt;span style="color: #0000ff"&gt;out&lt;/span&gt; accessorObject, &lt;span style="color: #0000ff"&gt;out&lt;/span&gt; indexedPropertyInfo);&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum173" style="color: #606060"&gt; 173:&lt;/span&gt;             &lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum174" style="color: #606060"&gt; 174:&lt;/span&gt;             &lt;span style="color: #008000"&gt;//Use reflection to get the data out of the SubPropertyAccessor&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum175" style="color: #606060"&gt; 175:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (indexedPropertyInfo != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum176" style="color: #606060"&gt; 176:&lt;/span&gt;                 indexedPropertyInfo.SetValue(accessorObject, &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;, &lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum177" style="color: #606060"&gt; 177:&lt;/span&gt;                     &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #0000ff"&gt;object&lt;/span&gt;[] {(DataGridView.Columns[ColumnIndex] &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; SubPropertyColumn).PropertyIndex });&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum178" style="color: #606060"&gt; 178:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum179" style="color: #606060"&gt; 179:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum180" style="color: #606060"&gt; 180:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum181" style="color: #606060"&gt; 181:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.SetValue(rowIndex, &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum182" style="color: #606060"&gt; 182:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;div class="CopyToClipboardOuter" &gt;&lt;div class="CopyToClipboardInner"&gt;&lt;a href="javascript:void(0);" title="View Plain" onclick="CopyToClipboard_ViewPlain(copyToClipboard200319f66a954592b09711aa4f568d73_123925);"&gt;View Plain&lt;/a&gt; &lt;/div&gt;&lt;/div&gt;
					&lt;script type="text/javascript"&gt;
						var copyToClipboard200319f66a954592b09711aa4f568d73_123925 = CopyToClipboard_Strip('        /// &amp;lt;summary&amp;gt;\r\n        /// Changes the value of a cell\r\n        /// &amp;lt;/summary&amp;gt;\r\n        /// &amp;lt;param name=&amp;quot;rowIndex&amp;quot;&amp;gt;The index of the cell\'s parent row.&amp;lt;/param&amp;gt;\r\n        /// &amp;lt;param name=&amp;quot;value&amp;quot;&amp;gt;The new value of the cell&amp;lt;/param&amp;gt;\r\n        /// &amp;lt;returns&amp;gt;A boolean that tells if the value was successfully changed in the underlying data.&amp;lt;/returns&amp;gt;\r\n        /// &amp;lt;remarks&amp;gt;It is here that the SubPropertyAccessor is used to put the correct value into the sub property.&amp;lt;/remarks&amp;gt;\r\n        protected override bool SetValue(int rowIndex, object value) {\r\n            if (DataGridView == null || DataGridView.RowCount &amp;lt;= 0) {\r\n                return base.SetValue(rowIndex, value);\r\n            }\r\n\r\n            //Get the SubPropertyAccessor and the PropertyInfo for the property \r\n            //on it that has the data needed\r\n            object accessorObject;\r\n            PropertyInfo indexedPropertyInfo;\r\n            getAccessor(rowIndex, out accessorObject, out indexedPropertyInfo);\r\n            \r\n            //Use reflection to get the data out of the SubPropertyAccessor\r\n            if (indexedPropertyInfo != null) {\r\n                indexedPropertyInfo.SetValue(accessorObject, value, \r\n                    new object[] {(DataGridView.Columns[ColumnIndex] as SubPropertyColumn).PropertyIndex });\r\n                return true;\r\n            }\r\n\r\n            return base.SetValue(rowIndex, value);\r\n        }');
					&lt;/script&gt;

&lt;h3&gt;&amp;#160;&lt;/h3&gt;

&lt;h3&gt;GetFormattedValue&lt;/h3&gt;

&lt;p&gt;The GetFormattedValue method is used by the DataGridView to convert data from the underlying data source into a format that can be presented in the grid.&amp;#160; Since the SubPropertyCell is derived from a DataGridTextBoxCell, I took a shortcut and converted everything to a string to be presented in the TextBox that the base DataGridTextBoxCell handles.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: hidden; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 1000px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4; text-align: left"&gt;
  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum46" style="color: #606060"&gt;  46:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum47" style="color: #606060"&gt;  47:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// Gets the value of the cell as formatted for display.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum48" style="color: #606060"&gt;  48:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum49" style="color: #606060"&gt;  49:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;value&amp;quot;&amp;gt;The value to be formatted.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum50" style="color: #606060"&gt;  50:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;rowIndex&amp;quot;&amp;gt;The index of the cell's parent row.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum51" style="color: #606060"&gt;  51:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;cellStyle&amp;quot;&amp;gt;The  DataGridViewCellStyle in effect for the cell.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum52" style="color: #606060"&gt;  52:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;valueTypeConverter&amp;quot;&amp;gt;A TypeConverter associated with the value type that provides custom conversion to the formatted value type.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum53" style="color: #606060"&gt;  53:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;formattedValueTypeConverter&amp;quot;&amp;gt;A TypeConverter associated with the formatted value type that provides custom conversion from the value type.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum54" style="color: #606060"&gt;  54:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;context&amp;quot;&amp;gt;A bitwise combination of  DataGridViewDataErrorContexts values describing the context in which the formatted value is needed.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum55" style="color: #606060"&gt;  55:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;returns&amp;gt;The formatted value of the cell&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum56" style="color: #606060"&gt;  56:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;remarks&amp;gt;Because this cell is based on a text box cell, it is assumed that the result should be a string.&amp;lt;/remarks&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum57" style="color: #606060"&gt;  57:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; GetFormattedValue(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; rowIndex, &lt;span style="color: #0000ff"&gt;ref&lt;/span&gt; DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum58" style="color: #606060"&gt;  58:&lt;/span&gt;             SubPropertyColumn column = DataGridView.Columns[ColumnIndex] &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; SubPropertyColumn;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum59" style="color: #606060"&gt;  59:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (column != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum60" style="color: #606060"&gt;  60:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (cellStyle.Format != &lt;span style="color: #0000ff"&gt;string&lt;/span&gt;.Empty) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum61" style="color: #606060"&gt;  61:&lt;/span&gt;                     &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; format = String.Format(&lt;span style="color: #006080"&gt;&amp;quot;{{0:{0}}}&amp;quot;&lt;/span&gt;, cellStyle.Format);&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum62" style="color: #606060"&gt;  62:&lt;/span&gt;                     &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt;.Format(format, &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum63" style="color: #606060"&gt;  63:&lt;/span&gt;                 }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum64" style="color: #606060"&gt;  64:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;else&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum65" style="color: #606060"&gt;  65:&lt;/span&gt;                     &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;.ToString();&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum66" style="color: #606060"&gt;  66:&lt;/span&gt;                 }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum67" style="color: #606060"&gt;  67:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum68" style="color: #606060"&gt;  68:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;else&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum69" style="color: #606060"&gt;  69:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.GetFormattedValue(&lt;span style="color: #0000ff"&gt;value&lt;/span&gt;, rowIndex, &lt;span style="color: #0000ff"&gt;ref&lt;/span&gt; cellStyle, valueTypeConverter, formattedValueTypeConverter, context);&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum70" style="color: #606060"&gt;  70:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum71" style="color: #606060"&gt;  71:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;div class="CopyToClipboardOuter" &gt;&lt;div class="CopyToClipboardInner"&gt;&lt;a href="javascript:void(0);" title="View Plain" onclick="CopyToClipboard_ViewPlain(copyToClipboard200319f66a954592b09711aa4f568d73_142628);"&gt;View Plain&lt;/a&gt; &lt;/div&gt;&lt;/div&gt;
					&lt;script type="text/javascript"&gt;
						var copyToClipboard200319f66a954592b09711aa4f568d73_142628 = CopyToClipboard_Strip('        /// &amp;lt;summary&amp;gt;\r\n        /// Gets the value of the cell as formatted for display.\r\n        /// &amp;lt;/summary&amp;gt;\r\n        /// &amp;lt;param name=&amp;quot;value&amp;quot;&amp;gt;The value to be formatted.&amp;lt;/param&amp;gt;\r\n        /// &amp;lt;param name=&amp;quot;rowIndex&amp;quot;&amp;gt;The index of the cell\'s parent row.&amp;lt;/param&amp;gt;\r\n        /// &amp;lt;param name=&amp;quot;cellStyle&amp;quot;&amp;gt;The  DataGridViewCellStyle in effect for the cell.&amp;lt;/param&amp;gt;\r\n        /// &amp;lt;param name=&amp;quot;valueTypeConverter&amp;quot;&amp;gt;A TypeConverter associated with the value type that provides custom conversion to the formatted value type.&amp;lt;/param&amp;gt;\r\n        /// &amp;lt;param name=&amp;quot;formattedValueTypeConverter&amp;quot;&amp;gt;A TypeConverter associated with the formatted value type that provides custom conversion from the value type.&amp;lt;/param&amp;gt;\r\n        /// &amp;lt;param name=&amp;quot;context&amp;quot;&amp;gt;A bitwise combination of  DataGridViewDataErrorContexts values describing the context in which the formatted value is needed.&amp;lt;/param&amp;gt;\r\n        /// &amp;lt;returns&amp;gt;The formatted value of the cell&amp;lt;/returns&amp;gt;\r\n        /// &amp;lt;remarks&amp;gt;Because this cell is based on a text box cell, it is assumed that the result should be a string.&amp;lt;/remarks&amp;gt;\r\n        protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context) {\r\n            SubPropertyColumn column = DataGridView.Columns[ColumnIndex] as SubPropertyColumn;\r\n            if (column != null) {\r\n                if (cellStyle.Format != string.Empty) {\r\n                    string format = String.Format(&amp;quot;{{0:{0}}}&amp;quot;, cellStyle.Format);\r\n                    return string.Format(format, value);\r\n                }\r\n                else {\r\n                    return value.ToString();\r\n                }\r\n            }\r\n            else {\r\n                return base.GetFormattedValue(value, rowIndex, ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context);\r\n            }\r\n        }');
					&lt;/script&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h3&gt;ParseFormattedValue&lt;/h3&gt;

&lt;p&gt;The ParseFormattedValue method is called by the DataGridView to convert data that was displayed in the grid into a format that can be stored in the underlying bound data source. Again, I took a shortcut and assumed that the grid would always be displaying strings.&amp;#160; The ParseFormattedValue uses the static Convert.ChangeType to convert strings into the required data type.&amp;#160; &lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: hidden; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 1000px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4; text-align: left"&gt;
  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum23" style="color: #606060"&gt;  23:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum24" style="color: #606060"&gt;  24:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// Takes the value that was in the cell and transforms it into the type as it is stored in the underlying data&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum25" style="color: #606060"&gt;  25:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum26" style="color: #606060"&gt;  26:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;formattedValue&amp;quot;&amp;gt;The value that was in the cell&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum27" style="color: #606060"&gt;  27:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;cellStyle&amp;quot;&amp;gt;The cell style from the cell&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum28" style="color: #606060"&gt;  28:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;formattedValueTypeConverter&amp;quot;&amp;gt;The type converter for the display value type&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum29" style="color: #606060"&gt;  29:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;valueTypeConverter&amp;quot;&amp;gt;The type converter for the value type&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum30" style="color: #606060"&gt;  30:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;returns&amp;gt;The value of the cell in the type of as it is stored in the underlying data.&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum31" style="color: #606060"&gt;  31:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;remarks&amp;gt;Since this cell is based on a text box cell, it is assumed that the type of the display data is string.&amp;lt;/remarks&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum32" style="color: #606060"&gt;  32:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; ParseFormattedValue(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; formattedValue, DataGridViewCellStyle cellStyle, TypeConverter formattedValueTypeConverter, TypeConverter valueTypeConverter) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum33" style="color: #606060"&gt;  33:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (formattedValue &lt;span style="color: #0000ff"&gt;is&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt;) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum34" style="color: #606060"&gt;  34:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; result = Convert.ChangeType(formattedValue, ValueType);&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum35" style="color: #606060"&gt;  35:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; result;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum36" style="color: #606060"&gt;  36:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum37" style="color: #606060"&gt;  37:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;else&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum38" style="color: #606060"&gt;  38:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.ParseFormattedValue(formattedValue, cellStyle, formattedValueTypeConverter, valueTypeConverter);&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum39" style="color: #606060"&gt;  39:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum40" style="color: #606060"&gt;  40:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;div class="CopyToClipboardOuter" &gt;&lt;div class="CopyToClipboardInner"&gt;&lt;a href="javascript:void(0);" title="View Plain" onclick="CopyToClipboard_ViewPlain(copyToClipboard200319f66a954592b09711aa4f568d73_156918);"&gt;View Plain&lt;/a&gt; &lt;/div&gt;&lt;/div&gt;
					&lt;script type="text/javascript"&gt;
						var copyToClipboard200319f66a954592b09711aa4f568d73_156918 = CopyToClipboard_Strip('        /// &amp;lt;summary&amp;gt;\r\n        /// Takes the value that was in the cell and transforms it into the type as it is stored in the underlying data\r\n        /// &amp;lt;/summary&amp;gt;\r\n        /// &amp;lt;param name=&amp;quot;formattedValue&amp;quot;&amp;gt;The value that was in the cell&amp;lt;/param&amp;gt;\r\n        /// &amp;lt;param name=&amp;quot;cellStyle&amp;quot;&amp;gt;The cell style from the cell&amp;lt;/param&amp;gt;\r\n        /// &amp;lt;param name=&amp;quot;formattedValueTypeConverter&amp;quot;&amp;gt;The type converter for the display value type&amp;lt;/param&amp;gt;\r\n        /// &amp;lt;param name=&amp;quot;valueTypeConverter&amp;quot;&amp;gt;The type converter for the value type&amp;gt;&amp;lt;/param&amp;gt;\r\n        /// &amp;lt;returns&amp;gt;The value of the cell in the type of as it is stored in the underlying data.&amp;lt;/returns&amp;gt;\r\n        /// &amp;lt;remarks&amp;gt;Since this cell is based on a text box cell, it is assumed that the type of the display data is string.&amp;lt;/remarks&amp;gt;\r\n        public override object ParseFormattedValue(object formattedValue, DataGridViewCellStyle cellStyle, TypeConverter formattedValueTypeConverter, TypeConverter valueTypeConverter) {\r\n            if (formattedValue is string) {\r\n                object result = Convert.ChangeType(formattedValue, ValueType);\r\n                return result;\r\n            }\r\n            else {\r\n                return base.ParseFormattedValue(formattedValue, cellStyle, formattedValueTypeConverter, valueTypeConverter);\r\n            }\r\n        }');
					&lt;/script&gt;

&lt;p&gt;There is no error handling here and it is very easy for an end user to cause an exception simply by entering the wrong data type into the grid.&amp;#160; &lt;/p&gt;

&lt;h2&gt;Demo&lt;/h2&gt;

&lt;p&gt;&lt;a href="http://www.dogspots.com/pictures/PresentingDetailValuesasPartoftheMasterp_98CF/EditColumns.png" target="_blank"&gt;&lt;img title="Edit Columns" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; margin-left: 0px; margin-right: 0px; border-right-width: 0px" height="244" alt="Edit Columns" src="http://www.dogspots.com/pictures/PresentingDetailValuesasPartoftheMasterp_98CF/EditColumns_thumb.png" width="233" align="right" border="0" /&gt;&lt;/a&gt; With what we already have, we can show sub-property values in a grid.&amp;#160; Using the same Linq-To-SQL classes from Part 1, we can point a BindingSource at the Song class and point a DataGridView at the DataSource.&amp;#160; &lt;/p&gt;

&lt;p&gt;In the screen shot of the Edit Columns dialog, we can see that there are five columns defined.&amp;#160; The Artist and Title columns are regular TextBoxColumns that get their data directly from the Song table in the database.&amp;#160; The Category, Score and Date columns, on the other hand, are SubPropertyColumns.&amp;#160; In the picture, the focus is on the Score column and we can see that IndexedPropertyName is set to “Properties” and PropertyIndex is set to “Rating”.&amp;#160; This is the equivalent of showing Song.Properties[“Rating”] in a column.&lt;/p&gt;

&lt;p&gt;When the program is run, the DataGridView works exactly as expected.&amp;#160; Rows and be added, deleted and edited.&amp;#160; Any changes to the Artist and Title columns are saved to Song table, but changes to the other columns are saved to the Attributes table.&amp;#160; As values are put in the cells in the Category, Score and Date columns, records are added to the Attributes table.&lt;/p&gt;

&lt;h1&gt;&amp;#160;&lt;/h1&gt;

&lt;h1&gt;Sorting&lt;/h1&gt;

&lt;p&gt;What we have so far is great, but if we tried to sort any of the SubProperty columns, they would not sort.&amp;#160; Sorting doesn’t work because the default sorting routine built into the DataGridView doesn’t know how to sort the data that we’ve put into the cells.&amp;#160; &lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.dogspots.com/pictures/PresentingDetailValuesasPartoftheMasterp_98CF/Exception.png" target="_blank"&gt;&lt;img title="Exception" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; margin: 0px 10px 0px 0px; border-right-width: 0px" height="137" alt="Exception" src="http://www.dogspots.com/pictures/PresentingDetailValuesasPartoftheMasterp_98CF/Exception_thumb.png" width="244" align="left" border="0" /&gt;&lt;/a&gt; Since we are dealing with bound data we cannot use programmatic sorting.&amp;#160; This would have been the easiest route to take we could call the sort method on the grid and pass in a specialized IComparer class that knows how to access the SubProperty data.&amp;#160; Unfortunately, the DataGridView doesn’t allow this when using bound data.&amp;#160; If we try it, we’ll get a runtime exception like the one pictured on the left.&amp;#160; &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Another option would be to put the sorting logic into a specialized collection class.&amp;#160; This gets complicated quickly and while it is possible, it limits how we can use our objects by limiting the collections that can can work with.&amp;#160; I really want the sorting to work no matter what kind of collection my objects are in.&amp;#160; I want this so I can continue to use something like Linq where I can easily call up a collection of my objects.&amp;#160; &lt;/p&gt;

&lt;p&gt;In parts one and two we’ve been working with a small sample database and some Linq-To-SQL classes.&amp;#160; We were able to add the sub property functionality to one of the Linq-To-SQL classes by simply editing the partial class part of the generated class and adding a SubPropertyAccessor to the class as a field.&amp;#160; All of the functionality is contained in the SubPropertyAccessor and is added to the business class with a few lines of code.&amp;#160; I want this same ease of use for the sorting functionality.&amp;#160; The best way to do this is to use a TypeDDescriptionProvider.&lt;/p&gt;

&lt;h2&gt;SubPropertyTypeDescriptionProvider&lt;/h2&gt;

&lt;p&gt;A type description provider is what provides the information about a type when reflection is used against that type.&amp;#160; If we create our own TypeDescriptionProvider, we can make is seem as though all of our sub-properties are actual properties of our type.&amp;#160; If our sub-properties appear as real properties of our type, the DataGridView should have no trouble sorting the column itself.&amp;#160; &lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: hidden; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 1000px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; height: 596px; background-color: #f4f4f4; text-align: left"&gt;
  &lt;div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum2" style="color: #606060"&gt;   2:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.ComponentModel;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum3" style="color: #606060"&gt;   3:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum4" style="color: #606060"&gt;   4:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; SubProperties {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum5" style="color: #606060"&gt;   5:&lt;/span&gt;     &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum6" style="color: #606060"&gt;   6:&lt;/span&gt;     &lt;span style="color: #008000"&gt;/// This class will provide a TypeDescriptor for a class that contains a SubPropertyAccessor.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum7" style="color: #606060"&gt;   7:&lt;/span&gt;     &lt;span style="color: #008000"&gt;/// The TypeDescriptor will report a property for each sub property that is available&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum8" style="color: #606060"&gt;   8:&lt;/span&gt;     &lt;span style="color: #008000"&gt;/// via the SubPropertyAccessor.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum9" style="color: #606060"&gt;   9:&lt;/span&gt;     &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum10" style="color: #606060"&gt;  10:&lt;/span&gt;     &lt;span style="color: #008000"&gt;/// &amp;lt;typeparam name=&amp;quot;T&amp;quot;&amp;gt;The type of the class that owns the SubPropertyAccessor&amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum11" style="color: #606060"&gt;  11:&lt;/span&gt;     &lt;span style="color: #008000"&gt;/// &amp;lt;typeparam name=&amp;quot;A&amp;quot;&amp;gt;The type of the class that contains the sub property data and that the accessor uses to get to that data.&amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum12" style="color: #606060"&gt;  12:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; SubPropertyTypeDescriptionProvider&amp;lt;T, A&amp;gt; : TypeDescriptionProvider &lt;span style="color: #0000ff"&gt;where&lt;/span&gt; T : ISubProperty&amp;lt;A&amp;gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum13" style="color: #606060"&gt;  13:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum14" style="color: #606060"&gt;  14:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; TypeDescriptionProvider defaultTypeProvider = TypeDescriptor.GetProvider(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(T));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum15" style="color: #606060"&gt;  15:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum16" style="color: #606060"&gt;  16:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; SubPropertyTypeDescriptionProvider() : &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;(defaultTypeProvider) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum17" style="color: #606060"&gt;  17:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum18" style="color: #606060"&gt;  18:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum19" style="color: #606060"&gt;  19:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum20" style="color: #606060"&gt;  20:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// Returns the SubPropertyTypeDescriptor for the given object type.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum21" style="color: #606060"&gt;  21:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum22" style="color: #606060"&gt;  22:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;objectType&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum23" style="color: #606060"&gt;  23:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;instance&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum24" style="color: #606060"&gt;  24:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum25" style="color: #606060"&gt;  25:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; ICustomTypeDescriptor GetTypeDescriptor(Type objectType, &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; instance) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum26" style="color: #606060"&gt;  26:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (!&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(T).IsAssignableFrom(objectType)) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum27" style="color: #606060"&gt;  27:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;throw&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ArgumentException(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;.Format(&lt;span style="color: #006080"&gt;&amp;quot;The objectType argument must be of type {0}&amp;quot;&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(T).Name), &lt;span style="color: #006080"&gt;&amp;quot;objectType&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum28" style="color: #606060"&gt;  28:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum29" style="color: #606060"&gt;  29:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum30" style="color: #606060"&gt;  30:&lt;/span&gt;             ICustomTypeDescriptor defaultDescriptor = &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.GetTypeDescriptor(objectType, instance);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum31" style="color: #606060"&gt;  31:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum32" style="color: #606060"&gt;  32:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SubPropertyTypeDescriptor&amp;lt;T, A&amp;gt;(defaultDescriptor, instance);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum33" style="color: #606060"&gt;  33:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum34" style="color: #606060"&gt;  34:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum35" style="color: #606060"&gt;  35:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum36" style="color: #606060"&gt;  36:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum37" style="color: #606060"&gt;  37:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="CopyToClipboardOuter" &gt;&lt;div class="CopyToClipboardInner"&gt;&lt;a href="javascript:void(0);" title="View Plain" onclick="CopyToClipboard_ViewPlain(copyToClipboard200319f66a954592b09711aa4f568d73_185292);"&gt;View Plain&lt;/a&gt; &lt;/div&gt;&lt;/div&gt;
					&lt;script type="text/javascript"&gt;
						var copyToClipboard200319f66a954592b09711aa4f568d73_185292 = CopyToClipboard_Strip('using System;\r\nusing System.ComponentModel;\r\n\r\nnamespace SubProperties {\r\n    /// &amp;lt;summary&amp;gt;\r\n    /// This class will provide a TypeDescriptor for a class that contains a SubPropertyAccessor.\r\n    /// The TypeDescriptor will report a property for each sub property that is available\r\n    /// via the SubPropertyAccessor.\r\n    /// &amp;lt;/summary&amp;gt;\r\n    /// &amp;lt;typeparam name=&amp;quot;T&amp;quot;&amp;gt;The type of the class that owns the SubPropertyAccessor&amp;lt;/typeparam&amp;gt;\r\n    /// &amp;lt;typeparam name=&amp;quot;A&amp;quot;&amp;gt;The type of the class that contains the sub property data and that the accessor uses to get to that data.&amp;lt;/typeparam&amp;gt;\r\n    class SubPropertyTypeDescriptionProvider&amp;lt;T, A&amp;gt; : TypeDescriptionProvider where T : ISubProperty&amp;lt;A&amp;gt; {\r\n\r\n        private static TypeDescriptionProvider defaultTypeProvider = TypeDescriptor.GetProvider(typeof(T));\r\n\r\n        public SubPropertyTypeDescriptionProvider() : base(defaultTypeProvider) {\r\n        }\r\n\r\n        /// &amp;lt;summary&amp;gt;\r\n        /// Returns the SubPropertyTypeDescriptor for the given object type.\r\n        /// &amp;lt;/summary&amp;gt;\r\n        /// &amp;lt;param name=&amp;quot;objectType&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;\r\n        /// &amp;lt;param name=&amp;quot;instance&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;\r\n        /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;\r\n        public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance) {\r\n            if (!typeof(T).IsAssignableFrom(objectType)) {\r\n                throw new ArgumentException(string.Format(&amp;quot;The objectType argument must be of type {0}&amp;quot;, typeof(T).Name), &amp;quot;objectType&amp;quot;);\r\n            }\r\n\r\n            ICustomTypeDescriptor defaultDescriptor = base.GetTypeDescriptor(objectType, instance);\r\n\r\n            return new SubPropertyTypeDescriptor&amp;lt;T, A&amp;gt;(defaultDescriptor, instance);\r\n        }\r\n\r\n    }\r\n\r\n}');
					&lt;/script&gt;

&lt;p&gt;Our SubPropertyTypeDescriptionProvider doesn’t do anything more than override GetTypeDescriptor to return a SubPropertyTypeDescriptor.&amp;#160; It is in SubPropertyTypeDescriptor where the work will be done.&lt;/p&gt;

&lt;h2&gt;SubPropertyTypeDescriptor &lt;/h2&gt;

&lt;p&gt;Our SubPropertyTypeDescriptor will need to return the list of actual properties as well as a list of our custom properties.&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 1000px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4; text-align: left"&gt;
  &lt;div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum2" style="color: #606060"&gt;   2:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum3" style="color: #606060"&gt;   3:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum4" style="color: #606060"&gt;   4:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.ComponentModel;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum5" style="color: #606060"&gt;   5:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Reflection;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum6" style="color: #606060"&gt;   6:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum7" style="color: #606060"&gt;   7:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; SubProperties {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum8" style="color: #606060"&gt;   8:&lt;/span&gt;     &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum9" style="color: #606060"&gt;   9:&lt;/span&gt;     &lt;span style="color: #008000"&gt;/// a TypeDescriptor for a class that contains a SubPropertyAccessor.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum10" style="color: #606060"&gt;  10:&lt;/span&gt;     &lt;span style="color: #008000"&gt;/// It will report a property for each sub property that is available&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum11" style="color: #606060"&gt;  11:&lt;/span&gt;     &lt;span style="color: #008000"&gt;/// via the SubPropertyAccessor.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum12" style="color: #606060"&gt;  12:&lt;/span&gt;     &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum13" style="color: #606060"&gt;  13:&lt;/span&gt;     &lt;span style="color: #008000"&gt;/// &amp;lt;typeparam name=&amp;quot;T&amp;quot;&amp;gt;The type of the class that owns the SubPropertyAccessor&amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum14" style="color: #606060"&gt;  14:&lt;/span&gt;     &lt;span style="color: #008000"&gt;/// &amp;lt;typeparam name=&amp;quot;A&amp;quot;&amp;gt;The type of the class that contains the sub property data and that the accessor uses to get to that data.&amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum15" style="color: #606060"&gt;  15:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; SubPropertyTypeDescriptor&amp;lt;T, A&amp;gt; : CustomTypeDescriptor &lt;span style="color: #0000ff"&gt;where&lt;/span&gt; T : ISubProperty&amp;lt;A&amp;gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum16" style="color: #606060"&gt;  16:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum17" style="color: #606060"&gt;  17:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; T fInstance;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum18" style="color: #606060"&gt;  18:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum19" style="color: #606060"&gt;  19:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum20" style="color: #606060"&gt;  20:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// A List of PropertyDescriptors for all of the custom properties.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum21" style="color: #606060"&gt;  21:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum22" style="color: #606060"&gt;  22:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; List&amp;lt;PropertyDescriptor&amp;gt; CustomProperties {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum23" style="color: #606060"&gt;  23:&lt;/span&gt;             get {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum24" style="color: #606060"&gt;  24:&lt;/span&gt;                 List&amp;lt;PropertyDescriptor&amp;gt; result = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;PropertyDescriptor&amp;gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum25" style="color: #606060"&gt;  25:&lt;/span&gt;                 result.AddRange(getCustomProrerties(fInstance).Select(f =&amp;gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; CustomPropertyDescriptor&amp;lt;T, A&amp;gt;(f)).Cast&amp;lt;PropertyDescriptor&amp;gt;());&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum26" style="color: #606060"&gt;  26:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; result;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum27" style="color: #606060"&gt;  27:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum28" style="color: #606060"&gt;  28:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum29" style="color: #606060"&gt;  29:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum30" style="color: #606060"&gt;  30:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum31" style="color: #606060"&gt;  31:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; SubPropertyTypeDescriptor(ICustomTypeDescriptor parent, &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; instance) : &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;(parent) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum32" style="color: #606060"&gt;  32:&lt;/span&gt;             fInstance = (T)instance;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum33" style="color: #606060"&gt;  33:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum34" style="color: #606060"&gt;  34:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum35" style="color: #606060"&gt;  35:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum36" style="color: #606060"&gt;  36:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// Returns all of the properties for class T including the custom properties that are actually data stored in the an object of class A&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum37" style="color: #606060"&gt;  37:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum38" style="color: #606060"&gt;  38:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;returns&amp;gt;The properties for class T including the custom properties that are actually data stored in the an object of class A&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum39" style="color: #606060"&gt;  39:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; PropertyDescriptorCollection GetProperties() {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum40" style="color: #606060"&gt;  40:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; PropertyDescriptorCollection(&lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.GetProperties().Cast&amp;lt;PropertyDescriptor&amp;gt;().Union(CustomProperties).ToArray());&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum41" style="color: #606060"&gt;  41:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum42" style="color: #606060"&gt;  42:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum43" style="color: #606060"&gt;  43:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum44" style="color: #606060"&gt;  44:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// Returns all of the properties for class T including the custom properties that are actually data stored in the an object of class A&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum45" style="color: #606060"&gt;  45:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// only the properties with the given attributes are returned.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum46" style="color: #606060"&gt;  46:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum47" style="color: #606060"&gt;  47:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;attributes&amp;quot;&amp;gt;Used to filter the results&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum48" style="color: #606060"&gt;  48:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;returns&amp;gt;The properties for class T including the custom properties that are actually data stored in the an object of class A&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum49" style="color: #606060"&gt;  49:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; PropertyDescriptorCollection GetProperties(System.Attribute[] attributes) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum50" style="color: #606060"&gt;  50:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; PropertyDescriptorCollection(&lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.GetProperties(attributes).Cast&amp;lt;PropertyDescriptor&amp;gt;().Union(CustomProperties).ToArray());&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum51" style="color: #606060"&gt;  51:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum52" style="color: #606060"&gt;  52:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum53" style="color: #606060"&gt;  53:&lt;/span&gt;         &lt;span style="color: #008000"&gt;//This generator will only work on classes that implement the ISubProperty&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum54" style="color: #606060"&gt;  54:&lt;/span&gt;         &lt;span style="color: #008000"&gt;//interface which requires all objects of the class to have&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum55" style="color: #606060"&gt;  55:&lt;/span&gt;         &lt;span style="color: #008000"&gt;//a property called Properties of type SubPropertyAccessor&amp;lt;A&amp;gt;.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum56" style="color: #606060"&gt;  56:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum57" style="color: #606060"&gt;  57:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; IEnumerable&amp;lt;CustomProperty&amp;gt; getCustomProperties(T tee) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum58" style="color: #606060"&gt;  58:&lt;/span&gt;             List&amp;lt;CustomProperty&amp;gt; customProperties = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;CustomProperty&amp;gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum59" style="color: #606060"&gt;  59:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum60" style="color: #606060"&gt;  60:&lt;/span&gt;             &lt;span style="color: #008000"&gt;//We may have an actual instance to work with&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum61" style="color: #606060"&gt;  61:&lt;/span&gt;             &lt;span style="color: #008000"&gt;//If so, check the Properties property of the object&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum62" style="color: #606060"&gt;  62:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (tee != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum63" style="color: #606060"&gt;  63:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (var propertyName &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; tee.Properties.PropertyNames) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum64" style="color: #606060"&gt;  64:&lt;/span&gt;                     customProperties.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; CustomProperty(propertyName, tee.Properties.PropertyType(propertyName)));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum65" style="color: #606060"&gt;  65:&lt;/span&gt;                 }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum66" style="color: #606060"&gt;  66:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum67" style="color: #606060"&gt;  67:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum68" style="color: #606060"&gt;  68:&lt;/span&gt;             &lt;span style="color: #008000"&gt;//If we don't have an instance object, use the static CustomProperties&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum69" style="color: #606060"&gt;  69:&lt;/span&gt;             &lt;span style="color: #008000"&gt;//property of the SubPropertyAccessor&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum70" style="color: #606060"&gt;  70:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;else&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum71" style="color: #606060"&gt;  71:&lt;/span&gt;                 Type aType = &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(SubPropertyAccessor&amp;lt;A&amp;gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum72" style="color: #606060"&gt;  72:&lt;/span&gt;                 PropertyInfo propertyInfo = aType.GetProperty(&lt;span style="color: #006080"&gt;&amp;quot;CustomProperties&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum73" style="color: #606060"&gt;  73:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; info = propertyInfo.GetValue(&lt;span style="color: #0000ff"&gt;null&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum74" style="color: #606060"&gt;  74:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (info != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; info &lt;span style="color: #0000ff"&gt;is&lt;/span&gt; Dictionary&amp;lt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;, Type&amp;gt;) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum75" style="color: #606060"&gt;  75:&lt;/span&gt;                     Dictionary&amp;lt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;, Type&amp;gt; properties = info &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; Dictionary&amp;lt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;, Type&amp;gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum76" style="color: #606060"&gt;  76:&lt;/span&gt;                     &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (var item &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; properties) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum77" style="color: #606060"&gt;  77:&lt;/span&gt;                         customProperties.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; CustomProperty(item.Key, item.Value));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum78" style="color: #606060"&gt;  78:&lt;/span&gt;                     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum79" style="color: #606060"&gt;  79:&lt;/span&gt;                 }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum80" style="color: #606060"&gt;  80:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum81" style="color: #606060"&gt;  81:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum82" style="color: #606060"&gt;  82:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; customProperties;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum83" style="color: #606060"&gt;  83:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum84" style="color: #606060"&gt;  84:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum85" style="color: #606060"&gt;  85:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum86" style="color: #606060"&gt;  86:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="CopyToClipboardOuter" &gt;&lt;div class="CopyToClipboardInner"&gt;&lt;a href="javascript:void(0);" title="View Plain" onclick="CopyToClipboard_ViewPlain(copyToClipboard200319f66a954592b09711aa4f568d73_237683);"&gt;View Plain&lt;/a&gt; &lt;/div&gt;&lt;/div&gt;
					&lt;script type="text/javascript"&gt;
						var copyToClipboard200319f66a954592b09711aa4f568d73_237683 = CopyToClipboard_Strip('using System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.ComponentModel;\r\nusing System.Reflection;\r\n\r\nnamespace SubProperties {\r\n    /// &amp;lt;summary&amp;gt;\r\n    /// a TypeDescriptor for a class that contains a SubPropertyAccessor.\r\n    /// It will report a property for each sub property that is available\r\n    /// via the SubPropertyAccessor.\r\n    /// &amp;lt;/summary&amp;gt;\r\n    /// &amp;lt;typeparam name=&amp;quot;T&amp;quot;&amp;gt;The type of the class that owns the SubPropertyAccessor&amp;lt;/typeparam&amp;gt;\r\n    /// &amp;lt;typeparam name=&amp;quot;A&amp;quot;&amp;gt;The type of the class that contains the sub property data and that the accessor uses to get to that data.&amp;lt;/typeparam&amp;gt;\r\n    class SubPropertyTypeDescriptor&amp;lt;T, A&amp;gt; : CustomTypeDescriptor where T : ISubProperty&amp;lt;A&amp;gt; {\r\n\r\n        private T fInstance;\r\n\r\n        /// &amp;lt;summary&amp;gt;\r\n        /// A List of PropertyDescriptors for all of the custom properties.\r\n        /// &amp;lt;/summary&amp;gt;\r\n        public List&amp;lt;PropertyDescriptor&amp;gt; CustomProperties {\r\n            get {\r\n                List&amp;lt;PropertyDescriptor&amp;gt; result = new List&amp;lt;PropertyDescriptor&amp;gt;();\r\n                result.AddRange(getCustomProrerties(fInstance).Select(f =&amp;gt; new CustomPropertyDescriptor&amp;lt;T, A&amp;gt;(f)).Cast&amp;lt;PropertyDescriptor&amp;gt;());\r\n                return result;\r\n            }\r\n        }\r\n        public SubPropertyTypeDescriptor(ICustomTypeDescriptor parent, object instance) : base(parent) {\r\n            fInstance = (T)instance;\r\n        }\r\n\r\n        /// &amp;lt;summary&amp;gt;\r\n        /// Returns all of the properties for class T including the custom properties that are actually data stored in the an object of class A\r\n        /// &amp;lt;/summary&amp;gt;\r\n        /// &amp;lt;returns&amp;gt;The properties for class T including the custom properties that are actually data stored in the an object of class A&amp;lt;/returns&amp;gt;\r\n        public override PropertyDescriptorCollection GetProperties() {\r\n            return new PropertyDescriptorCollection(base.GetProperties().Cast&amp;lt;PropertyDescriptor&amp;gt;().Union(CustomProperties).ToArray());\r\n        }\r\n\r\n        /// &amp;lt;summary&amp;gt;\r\n        /// Returns all of the properties for class T including the custom properties that are actually data stored in the an object of class A\r\n        /// only the properties with the given attributes are returned.\r\n        /// &amp;lt;/summary&amp;gt;\r\n        /// &amp;lt;param name=&amp;quot;attributes&amp;quot;&amp;gt;Used to filter the results&amp;lt;/param&amp;gt;\r\n        /// &amp;lt;returns&amp;gt;The properties for class T including the custom properties that are actually data stored in the an object of class A&amp;lt;/returns&amp;gt;\r\n        public override PropertyDescriptorCollection GetProperties(System.Attribute[] attributes) {\r\n            return new PropertyDescriptorCollection(base.GetProperties(attributes).Cast&amp;lt;PropertyDescriptor&amp;gt;().Union(CustomProperties).ToArray());\r\n        }\r\n\r\n        //This generator will only work on classes that implement the ISubProperty\r\n        //interface which requires all objects of the class to have\r\n        //a property called Properties of type SubPropertyAccessor&amp;lt;A&amp;gt;.\r\n\r\n        private static IEnumerable&amp;lt;CustomProperty&amp;gt; getCustomProperties(T tee) {\r\n            List&amp;lt;CustomProperty&amp;gt; customProperties = new List&amp;lt;CustomProperty&amp;gt;();\r\n\r\n            //We may have an actual instance to work with\r\n            //If so, check the Properties property of the object\r\n            if (tee != null) {\r\n                foreach (var propertyName in tee.Properties.PropertyNames) {\r\n                    customProperties.Add(new CustomProperty(propertyName, tee.Properties.PropertyType(propertyName)));\r\n                }\r\n            }\r\n\r\n            //If we don\'t have an instance object, use the static CustomProperties\r\n            //property of the SubPropertyAccessor\r\n            else {\r\n                Type aType = typeof(SubPropertyAccessor&amp;lt;A&amp;gt;);\r\n                PropertyInfo propertyInfo = aType.GetProperty(&amp;quot;CustomProperties&amp;quot;);\r\n                object info = propertyInfo.GetValue(null, null);\r\n                if (info != null &amp;amp;&amp;amp; info is Dictionary&amp;lt;string, Type&amp;gt;) {\r\n                    Dictionary&amp;lt;string, Type&amp;gt; properties = info as Dictionary&amp;lt;string, Type&amp;gt;;\r\n                    foreach (var item in properties) {\r\n                        customProperties.Add(new CustomProperty(item.Key, item.Value));\r\n                    }\r\n                }\r\n            }\r\n\r\n            return customProperties;\r\n        }\r\n\r\n    }\r\n}');
					&lt;/script&gt;

&lt;p&gt;The SubPropertyTypeDescriptor overrides the GetProperties method to return a list of properties that includes the properties that normally would be returned as well as a list of custom properties.&amp;#160; In order for it to work, it requires that the class we are working with implement the ISubProperty interface.&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; float: right; padding-bottom: 4px; margin: 0px 0px 10px; overflow: hidden; border-left: silver 1px solid; width: 60.64%; cursor: text; direction: ltr; max-height: 1000px; line-height: 12pt; padding-top: 0px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; height: 192px; background-color: #f4f4f4; text-align: left"&gt;
  &lt;div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum2" style="color: #606060"&gt;   2:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum3" style="color: #606060"&gt;   3:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; SubProperties {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum4" style="color: #606060"&gt;   4:&lt;/span&gt;     &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum5" style="color: #606060"&gt;   5:&lt;/span&gt;     &lt;span style="color: #008000"&gt;/// This interface must be implemented on any class &lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum6" style="color: #606060"&gt;   6:&lt;/span&gt;     &lt;span style="color: #008000"&gt;/// that uses the CustomPropertyDescriptor&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum7" style="color: #606060"&gt;   7:&lt;/span&gt;     &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum8" style="color: #606060"&gt;   8:&lt;/span&gt;     &lt;span style="color: #008000"&gt;/// &amp;lt;typeparam name=&amp;quot;T&amp;quot;&amp;gt;&amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum9" style="color: #606060"&gt;   9:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;interface&lt;/span&gt; ISubProperty&amp;lt;T&amp;gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum10" style="color: #606060"&gt;  10:&lt;/span&gt;         SubPropertyAccessor&amp;lt;T&amp;gt; Properties { get; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum11" style="color: #606060"&gt;  11:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum12" style="color: #606060"&gt;  12:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="CopyToClipboardOuter" &gt;&lt;div class="CopyToClipboardInner"&gt;&lt;a href="javascript:void(0);" title="View Plain" onclick="CopyToClipboard_ViewPlain(copyToClipboard200319f66a954592b09711aa4f568d73_250475);"&gt;View Plain&lt;/a&gt; &lt;/div&gt;&lt;/div&gt;
					&lt;script type="text/javascript"&gt;
						var copyToClipboard200319f66a954592b09711aa4f568d73_250475 = CopyToClipboard_Strip('using System;\r\n\r\nnamespace SubProperties {\r\n    /// &amp;lt;summary&amp;gt;\r\n    /// This interface must be implemented on any class \r\n    /// that uses the CustomPropertyDescriptor\r\n    /// &amp;lt;/summary&amp;gt;\r\n    /// &amp;lt;typeparam name=&amp;quot;T&amp;quot;&amp;gt;&amp;lt;/typeparam&amp;gt;\r\n    interface ISubProperty&amp;lt;T&amp;gt; {\r\n        SubPropertyAccessor&amp;lt;T&amp;gt; Properties { get; }\r\n    }\r\n}');
					&lt;/script&gt;

&lt;p&gt;The ISubProperty interface requires that the class we are working with have a property that is called “Properties” of the type SubPropertiesAccessor&amp;lt;T&amp;gt;.&lt;/p&gt;

&lt;p&gt;When we were working in the Cell and Column overrides, we could allow the SubPropertyAccessor be named anything and it could be specified at design time as a property on the column.&amp;#160; The TypeDescriptionProvider will be applied to the business class as an attribute on the class.&amp;#160; There is no way to tell the TypeDescriptionProvider what the SubPropertyAccessor will be called.&amp;#160; &lt;/p&gt;

&lt;p&gt;We can however make our TypeDescriptionProvider a generic class.&amp;#160; By doing that, we can specify what classes and interfaces it will work with by putting a constraint on the Type the generic class can work with.&amp;#160; Our constraint, which passes down from The TypeDescriptionProvider to the TypeDescriptor requires the ISubProperty interface and that interface tells us that the SubPropertyAccessor is always going to be named “Properties”.&lt;/p&gt;

&lt;p&gt;Having this constraint does, as its name implies, put a constraint on our classes, but I couldn’t figure out how to do sorting without it.&amp;#160; Also, I think the benefits that the custom TypeDescriptor provide out weigh the cost of the constraint.&lt;/p&gt;

&lt;h2&gt;SubPropertyAccessor&lt;/h2&gt;

&lt;p&gt;When the type descriptor has an object instance, it’s easy to see that it accesses the SubPropertyAccessor to figure out what the custom properties are, but how does it do it when there is no instance object?&lt;/p&gt;

&lt;p&gt;The answer is in the SubPropertyAccessor itself.&amp;#160; It now contains a static Dictionary of all of the custom properties that are created for any particular type.&amp;#160; Since the SubPropertyAccessor is a generic class each type that is used with it actually creates a unique type.&amp;#160; This means that there will be a single static Dictionary for each unique type. &lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: hidden; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 1000px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4; text-align: left"&gt;
  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum174" style="color: #606060"&gt; 174:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum175" style="color: #606060"&gt; 175:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// A list of custom properties that are available for type T.  This is a static list that is common to all instances of type T.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum176" style="color: #606060"&gt; 176:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum177" style="color: #606060"&gt; 177:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; Dictionary&amp;lt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;, Type&amp;gt; CustomProperties {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum178" style="color: #606060"&gt; 178:&lt;/span&gt;             get {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum179" style="color: #606060"&gt; 179:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; fCustomProperties;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum180" style="color: #606060"&gt; 180:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum181" style="color: #606060"&gt; 181:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;div class="CopyToClipboardOuter" &gt;&lt;div class="CopyToClipboardInner"&gt;&lt;a href="javascript:void(0);" title="View Plain" onclick="CopyToClipboard_ViewPlain(copyToClipboard200319f66a954592b09711aa4f568d73_258111);"&gt;View Plain&lt;/a&gt; &lt;/div&gt;&lt;/div&gt;
					&lt;script type="text/javascript"&gt;
						var copyToClipboard200319f66a954592b09711aa4f568d73_258111 = CopyToClipboard_Strip('        /// &amp;lt;summary&amp;gt;\r\n        /// A list of custom properties that are available for type T.  This is a static list that is common to all instances of type T.\r\n        /// &amp;lt;/summary&amp;gt;\r\n        public static Dictionary&amp;lt;string, Type&amp;gt; CustomProperties {\r\n            get {\r\n                return fCustomProperties;\r\n            }\r\n        }');
					&lt;/script&gt;

&lt;p&gt;The dictionary of custom properties get populated whenever a new instance of a SubPropertyAccessor is created.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: hidden; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 1000px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4; text-align: left"&gt;
  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum79" style="color: #606060"&gt;  79:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum80" style="color: #606060"&gt;  80:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// Constructor for the SubPropertyAccessor&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum81" style="color: #606060"&gt;  81:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum82" style="color: #606060"&gt;  82:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;parent&amp;quot;&amp;gt;The main object that will be accessed using this accessor.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum83" style="color: #606060"&gt;  83:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;propertyName&amp;quot;&amp;gt;The property on the parent object that holds a list of child objects.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum84" style="color: #606060"&gt;  84:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;propertyName&amp;quot;&amp;gt;The property on the child object that will be the key of the sub attributes.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum85" style="color: #606060"&gt;  85:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;valueName&amp;quot;&amp;gt;The property on the child object that will be the value of the sub attributes.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum86" style="color: #606060"&gt;  86:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; SubPropertyAccessor(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; parent,&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum87" style="color: #606060"&gt;  87:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; propertyName,&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum88" style="color: #606060"&gt;  88:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; propertyName,&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum89" style="color: #606060"&gt;  89:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; valueName) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum90" style="color: #606060"&gt;  90:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum91" style="color: #606060"&gt;  91:&lt;/span&gt;             fParent = parent;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum92" style="color: #606060"&gt;  92:&lt;/span&gt;             fPropertyName = propertyName;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum93" style="color: #606060"&gt;  93:&lt;/span&gt;             fKeyPropertyName = propertyName;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum94" style="color: #606060"&gt;  94:&lt;/span&gt;             fValuePropertyName = valueName;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum95" style="color: #606060"&gt;  95:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;span&gt;... &lt;/span&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum142" style="color: #606060"&gt; 142:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (var property &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; PropertyNames) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum143" style="color: #606060"&gt; 143:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (!CustomProperties.ContainsKey(property)) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum144" style="color: #606060"&gt; 144:&lt;/span&gt;                     CustomProperties.Add(property, PropertyType(property));&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum145" style="color: #606060"&gt; 145:&lt;/span&gt;                 }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum146" style="color: #606060"&gt; 146:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum147" style="color: #606060"&gt; 147:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum148" style="color: #606060"&gt; 148:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;div class="CopyToClipboardOuter" &gt;&lt;div class="CopyToClipboardInner"&gt;&lt;a href="javascript:void(0);" title="View Plain" onclick="CopyToClipboard_ViewPlain(copyToClipboard200319f66a954592b09711aa4f568d73_272799);"&gt;View Plain&lt;/a&gt; &lt;/div&gt;&lt;/div&gt;
					&lt;script type="text/javascript"&gt;
						var copyToClipboard200319f66a954592b09711aa4f568d73_272799 = CopyToClipboard_Strip('        /// &amp;lt;summary&amp;gt;\r\n        /// Constructor for the SubPropertyAccessor\r\n        /// &amp;lt;/summary&amp;gt;\r\n        /// &amp;lt;param name=&amp;quot;parent&amp;quot;&amp;gt;The main object that will be accessed using this accessor.&amp;lt;/param&amp;gt;\r\n        /// &amp;lt;param name=&amp;quot;propertyName&amp;quot;&amp;gt;The property on the parent object that holds a list of child objects.&amp;lt;/param&amp;gt;\r\n        /// &amp;lt;param name=&amp;quot;propertyName&amp;quot;&amp;gt;The property on the child object that will be the key of the sub attributes.&amp;lt;/param&amp;gt;\r\n        /// &amp;lt;param name=&amp;quot;valueName&amp;quot;&amp;gt;The property on the child object that will be the value of the sub attributes.&amp;lt;/param&amp;gt;\r\n        public SubPropertyAccessor(object parent,\r\n            string propertyName,\r\n            string propertyName,\r\n            string valueName) {\r\n\r\n            fParent = parent;\r\n            fPropertyName = propertyName;\r\n            fKeyPropertyName = propertyName;\r\n            fValuePropertyName = valueName;\r\n\r\n... \r\n            foreach (var property in PropertyNames) {\r\n                if (!CustomProperties.ContainsKey(property)) {\r\n                    CustomProperties.Add(property, PropertyType(property));\r\n                }\r\n            }\r\n\r\n        }');
					&lt;/script&gt;

&lt;p&gt;It also gets updated whenever a new custom property is added.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: hidden; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 1000px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4; text-align: left"&gt;
  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum192" style="color: #606060"&gt; 192:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum193" style="color: #606060"&gt; 193:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// This is the indexed property that provides access to &lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum194" style="color: #606060"&gt; 194:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// the list of child attributes.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum195" style="color: #606060"&gt; 195:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum196" style="color: #606060"&gt; 196:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;index&amp;quot;&amp;gt;The value of the key property on the object to be looked up&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum197" style="color: #606060"&gt; 197:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;returns&amp;gt;The value of the value property on the object that has the matching key property&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum198" style="color: #606060"&gt; 198:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;[&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; index] {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum199" style="color: #606060"&gt; 199:&lt;/span&gt;             get {&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;span&gt;...&lt;/span&gt; 

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum256" style="color: #606060"&gt; 256:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; result;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum257" style="color: #606060"&gt; 257:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum258" style="color: #606060"&gt; 258:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum259" style="color: #606060"&gt; 259:&lt;/span&gt;             set {&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;span&gt;...&lt;/span&gt; 

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum300" style="color: #606060"&gt; 300:&lt;/span&gt;                 &lt;span style="color: #008000"&gt;//Keep the list of custom properties up to date.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum301" style="color: #606060"&gt; 301:&lt;/span&gt;                 Type valueType = &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;.GetType();&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum302" style="color: #606060"&gt; 302:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (CustomProperties.ContainsKey(index)) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum303" style="color: #606060"&gt; 303:&lt;/span&gt;                     CustomProperties[index] = valueType;&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum304" style="color: #606060"&gt; 304:&lt;/span&gt;                 }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum305" style="color: #606060"&gt; 305:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;else&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum306" style="color: #606060"&gt; 306:&lt;/span&gt;                     CustomProperties.Add(index, valueType);&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum307" style="color: #606060"&gt; 307:&lt;/span&gt;                 }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum308" style="color: #606060"&gt; 308:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum309" style="color: #606060"&gt; 309:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum310" style="color: #606060"&gt; 310:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;div class="CopyToClipboardOuter" &gt;&lt;div class="CopyToClipboardInner"&gt;&lt;a href="javascript:void(0);" title="View Plain" onclick="CopyToClipboard_ViewPlain(copyToClipboard200319f66a954592b09711aa4f568d73_287603);"&gt;View Plain&lt;/a&gt; &lt;/div&gt;&lt;/div&gt;
					&lt;script type="text/javascript"&gt;
						var copyToClipboard200319f66a954592b09711aa4f568d73_287603 = CopyToClipboard_Strip('        /// &amp;lt;summary&amp;gt;\r\n        /// This is the indexed property that provides access to \r\n        /// the list of child attributes.\r\n        /// &amp;lt;/summary&amp;gt;\r\n        /// &amp;lt;param name=&amp;quot;index&amp;quot;&amp;gt;The value of the key property on the object to be looked up&amp;lt;/param&amp;gt;\r\n        /// &amp;lt;returns&amp;gt;The value of the value property on the object that has the matching key property&amp;lt;/returns&amp;gt;\r\n        public object this[string index] {\r\n            get {\r\n... \r\n                return result;\r\n            }\r\n\r\n            set {\r\n... \r\n                //Keep the list of custom properties up to date.\r\n                Type valueType = value.GetType();\r\n                if (CustomProperties.ContainsKey(index)) {\r\n                    CustomProperties[index] = valueType;\r\n                }\r\n                else {\r\n                    CustomProperties.Add(index, valueType);\r\n                }\r\n\r\n            }\r\n        }');
					&lt;/script&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h2&gt;Song&lt;/h2&gt;

&lt;p&gt;Let’s take a look at what our business class looks like now.&lt;/p&gt;

&lt;h2&gt;&lt;/h2&gt;

&lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: hidden; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 1000px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; height: 743px; background-color: #f4f4f4; text-align: left"&gt;
  &lt;div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; SubProperties {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum2" style="color: #606060"&gt;   2:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.ComponentModel;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum3" style="color: #606060"&gt;   3:&lt;/span&gt;     &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum4" style="color: #606060"&gt;   4:&lt;/span&gt;     [TypeDescriptionProvider(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(SubPropertyTypeDescriptionProvider&amp;lt;Song, Attribute&amp;gt;))]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum5" style="color: #606060"&gt;   5:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;partial&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; Song : ISubProperty&amp;lt;Attribute&amp;gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum6" style="color: #606060"&gt;   6:&lt;/span&gt;         &lt;span style="color: #008000"&gt;//The TypeDescriptionProvider makes the sub properties actually appear as properties of the object.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum7" style="color: #606060"&gt;   7:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum8" style="color: #606060"&gt;   8:&lt;/span&gt;         &lt;span style="color: #008000"&gt;//This is the SubPropertyAccessor that will provide the sub property functionality &lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum9" style="color: #606060"&gt;   9:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; SubPropertyAccessor&amp;lt;Attribute&amp;gt; fProperties = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum10" style="color: #606060"&gt;  10:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum11" style="color: #606060"&gt;  11:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;partial&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; OnLoaded() {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum12" style="color: #606060"&gt;  12:&lt;/span&gt;             &lt;span style="color: #008000"&gt;//In order for the TypeDescriptionProvider to &amp;quot;see&amp;quot; all of the sub properties, the SubPropertyAccessor&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum13" style="color: #606060"&gt;  13:&lt;/span&gt;             &lt;span style="color: #008000"&gt;//needs to be created as soon as the data is loaded.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum14" style="color: #606060"&gt;  14:&lt;/span&gt;             fProperties = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SubPropertyAccessor&amp;lt;Attribute&amp;gt;(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;Attributes&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;PropertyName&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;Value&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum15" style="color: #606060"&gt;  15:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum16" style="color: #606060"&gt;  16:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum17" style="color: #606060"&gt;  17:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum18" style="color: #606060"&gt;  18:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// Used to access the SubPropertiesAccessor class which&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum19" style="color: #606060"&gt;  19:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// has an indexed property to access the additional properties.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum20" style="color: #606060"&gt;  20:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// This property needs to be here to satisfy the ISubProperty interface.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum21" style="color: #606060"&gt;  21:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum22" style="color: #606060"&gt;  22:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; SubPropertyAccessor&amp;lt;Attribute&amp;gt; Properties {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum23" style="color: #606060"&gt;  23:&lt;/span&gt;             get {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum24" style="color: #606060"&gt;  24:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; fProperties;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum25" style="color: #606060"&gt;  25:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum26" style="color: #606060"&gt;  26:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum27" style="color: #606060"&gt;  27:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum28" style="color: #606060"&gt;  28:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum29" style="color: #606060"&gt;  29:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// This is the default indexed property&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum30" style="color: #606060"&gt;  30:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// It is just a wrapper around the Properties property&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum31" style="color: #606060"&gt;  31:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// that allows us to access the functionality without having&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum32" style="color: #606060"&gt;  32:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// to use the Properties name.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum33" style="color: #606060"&gt;  33:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum34" style="color: #606060"&gt;  34:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;index&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum35" style="color: #606060"&gt;  35:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum36" style="color: #606060"&gt;  36:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;[&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; index] {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum37" style="color: #606060"&gt;  37:&lt;/span&gt;             get {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum38" style="color: #606060"&gt;  38:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; Properties[index];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum39" style="color: #606060"&gt;  39:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum40" style="color: #606060"&gt;  40:&lt;/span&gt;             set {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum41" style="color: #606060"&gt;  41:&lt;/span&gt;                 Properties[index] = &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum42" style="color: #606060"&gt;  42:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum43" style="color: #606060"&gt;  43:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum44" style="color: #606060"&gt;  44:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum45" style="color: #606060"&gt;  45:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum46" style="color: #606060"&gt;  46:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="CopyToClipboardOuter" &gt;&lt;div class="CopyToClipboardInner"&gt;&lt;a href="javascript:void(0);" title="View Plain" onclick="CopyToClipboard_ViewPlain(copyToClipboard200319f66a954592b09711aa4f568d73_315510);"&gt;View Plain&lt;/a&gt; &lt;/div&gt;&lt;/div&gt;
					&lt;script type="text/javascript"&gt;
						var copyToClipboard200319f66a954592b09711aa4f568d73_315510 = CopyToClipboard_Strip('namespace SubProperties {\r\n    using System.ComponentModel;\r\n    \r\n    [TypeDescriptionProvider(typeof(SubPropertyTypeDescriptionProvider&amp;lt;Song, Attribute&amp;gt;))]\r\n    partial class Song : ISubProperty&amp;lt;Attribute&amp;gt; {\r\n        //The TypeDescriptionProvider makes the sub properties actually appear as properties of the object.\r\n\r\n        //This is the SubPropertyAccessor that will provide the sub property functionality \r\n        private SubPropertyAccessor&amp;lt;Attribute&amp;gt; fProperties = null;\r\n\r\n        partial void OnLoaded() {\r\n            //In order for the TypeDescriptionProvider to &amp;quot;see&amp;quot; all of the sub properties, the SubPropertyAccessor\r\n            //needs to be created as soon as the data is loaded.\r\n            fProperties = new SubPropertyAccessor&amp;lt;Attribute&amp;gt;(this, &amp;quot;Attributes&amp;quot;, &amp;quot;PropertyName&amp;quot;, &amp;quot;Value&amp;quot;);\r\n        }\r\n\r\n        /// &amp;lt;summary&amp;gt;\r\n        /// Used to access the SubPropertiesAccessor class which\r\n        /// has an indexed property to access the additional properties.\r\n        /// This property needs to be here to satisfy the ISubProperty interface.\r\n        /// &amp;lt;/summary&amp;gt;\r\n        public SubPropertyAccessor&amp;lt;Attribute&amp;gt; Properties {\r\n            get {\r\n                return fProperties;\r\n            }\r\n        }\r\n\r\n        /// &amp;lt;summary&amp;gt;\r\n        /// This is the default indexed property\r\n        /// It is just a wrapper around the Properties property\r\n        /// that allows us to access the functionality without having\r\n        /// to use the Properties name.\r\n        /// &amp;lt;/summary&amp;gt;\r\n        /// &amp;lt;param name=&amp;quot;index&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;\r\n        /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;\r\n        public object this[string index] {\r\n            get {\r\n                return Properties[index];\r\n            }\r\n            set {\r\n                Properties[index] = value;\r\n            }\r\n        }\r\n\r\n    }\r\n}');
					&lt;/script&gt;

&lt;p&gt;We’ve had to make a few changes to the class, but they are negligible compared to the functionality we will get.&amp;#160; &lt;/p&gt;

&lt;p&gt;With the exception of the Song class itself all of the code we have written is generic and can be used over and over by making the changes that we’ve made in the Song class.&amp;#160; The changes to the Song class amount to 46 lines and that includes verbose commenting. &lt;/p&gt;

&lt;p&gt;One change is the addition of the TypeDescriptionProvider attribute on line 4.&amp;#160; This tells the framework to use our SubPropertyTypeDescriptionProvider when using reflection on our Song class.&lt;/p&gt;

&lt;p&gt;The Song class now implements the ISubProperty&amp;lt;T&amp;gt; interface as indicated on line 5.&amp;#160; Our SubPropertyAccessor was already named “Properties”, so we didn’t have to make any changes there.&lt;/p&gt;

&lt;p&gt;Finally, at line 14, we construct the SubPropertyAccessor as soon as the data is loaded.&amp;#160; This will populate the static CustomProperties dictionary on the SubPropertyAccessor as soon as possible.&lt;/p&gt;

&lt;p&gt;Now when we try to sort our columns, everything should just work.&lt;/p&gt;

&lt;h2&gt;Demo&lt;/h2&gt;

&lt;p&gt;&lt;a href="http://www.dogspots.com/pictures/PresentingDetailValuesasPartoftheMasterp_98CF/Demo1.png" target="_blank"&gt;&lt;img title="Demo1" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; margin-left: 0px; margin-right: 0px; border-right-width: 0px" height="67" alt="Demo1" src="http://www.dogspots.com/pictures/PresentingDetailValuesasPartoftheMasterp_98CF/Demo1_thumb.png" width="244" align="right" border="0" /&gt;&lt;/a&gt; Here we can see that the dates are sorted and sorted correctly by date rather than alphabetically.&amp;#160; All of this sorting was handled by the grid itself.&amp;#160; All we did was provide a way for the grid to learn about our virtual properties.&lt;/p&gt;

&lt;h1&gt;Bonus – Dynamic Runtime Properties&lt;/h1&gt;

&lt;p&gt;I did cheat a little.&amp;#160; In the constructor for the example form, I pre-loaded the static Dictionary of custom properties on the SubPropertyAccessor with two properties that I knew about beforehand.&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: hidden; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 1000px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4; text-align: left"&gt;
  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum7" style="color: #606060"&gt;   7:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; Form1() {&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum8" style="color: #606060"&gt;   8:&lt;/span&gt;             SubPropertyAccessor&amp;lt;Attribute&amp;gt;.CustomProperties.Add(&lt;span style="color: #006080"&gt;&amp;quot;Rating&amp;quot;&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;));&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum9" style="color: #606060"&gt;   9:&lt;/span&gt;             SubPropertyAccessor&amp;lt;Attribute&amp;gt;.CustomProperties.Add(&lt;span style="color: #006080"&gt;&amp;quot;Date&amp;quot;&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(DateTime));&lt;/pre&gt;
&lt;!--CRLF--&gt;

  &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum10" style="color: #606060"&gt;  10:&lt;/span&gt;             InitializeComponent();&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;div class="CopyToClipboardOuter" &gt;&lt;div class="CopyToClipboardInner"&gt;&lt;a href="javascript:void(0);" title="View Plain" onclick="CopyToClipboard_ViewPlain(copyToClipboard200319f66a954592b09711aa4f568d73_322915);"&gt;View Plain&lt;/a&gt; &lt;/div&gt;&lt;/div&gt;
					&lt;script type="text/javascript"&gt;
						var copyToClipboard200319f66a954592b09711aa4f568d73_322915 = CopyToClipboard_Strip('        public Form1() {\r\n            SubPropertyAccessor&amp;lt;Attribute&amp;gt;.CustomProperties.Add(&amp;quot;Rating&amp;quot;, typeof(int));\r\n            SubPropertyAccessor&amp;lt;Attribute&amp;gt;.CustomProperties.Add(&amp;quot;Date&amp;quot;, typeof(DateTime));\r\n            InitializeComponent();');
					&lt;/script&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;But what happens if we want to add a property at run-time?&amp;#160; The same syntax can be used.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.dogspots.com/pictures/PresentingDetailValuesasPartoftheMasterp_98CF/Demo2.png" target="_blank"&gt;&lt;img title="Demo2" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; margin: 0px 10px 0px 0px; border-right-width: 0px" height="83" alt="Demo2" src="http://www.dogspots.com/pictures/PresentingDetailValuesasPartoftheMasterp_98CF/Demo2_thumb.png" width="244" align="left" border="0" /&gt;&lt;/a&gt; I added a few controls to the form that allow me to add a property at run time.&amp;#160; A TextBox allows me to specify the name of the property, a dropdown lets me choose the type and a button creates the property.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: hidden; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 1000px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4; text-align: left"&gt;
  &lt;div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum25" style="color: #606060"&gt;  25:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; loadGrid() {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum26" style="color: #606060"&gt;  26:&lt;/span&gt;             fContext.SubmitChanges();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum27" style="color: #606060"&gt;  27:&lt;/span&gt;             var result = from aSong &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; fContext.Songs select aSong;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum28" style="color: #606060"&gt;  28:&lt;/span&gt;             songBindingSource.DataSource = result;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum29" style="color: #606060"&gt;  29:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum30" style="color: #606060"&gt;  30:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum31" style="color: #606060"&gt;  31:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; button1_Click(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; sender, EventArgs e) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum32" style="color: #606060"&gt;  32:&lt;/span&gt;             Type aType = &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum33" style="color: #606060"&gt;  33:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum34" style="color: #606060"&gt;  34:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (comboBox1.SelectedItem.ToString() == &lt;span style="color: #006080"&gt;&amp;quot;Integer&amp;quot;&lt;/span&gt;) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum35" style="color: #606060"&gt;  35:&lt;/span&gt;                 aType = &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum36" style="color: #606060"&gt;  36:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum37" style="color: #606060"&gt;  37:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;else&lt;/span&gt; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (comboBox1.SelectedItem.ToString() == &lt;span style="color: #006080"&gt;&amp;quot;Double&amp;quot;&lt;/span&gt;) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum38" style="color: #606060"&gt;  38:&lt;/span&gt;                 aType = &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;double&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum39" style="color: #606060"&gt;  39:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum40" style="color: #606060"&gt;  40:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;else&lt;/span&gt; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (comboBox1.SelectedItem.ToString() == &lt;span style="color: #006080"&gt;&amp;quot;Date&amp;quot;&lt;/span&gt;) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum41" style="color: #606060"&gt;  41:&lt;/span&gt;                 aType = &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(DateTime);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum42" style="color: #606060"&gt;  42:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum43" style="color: #606060"&gt;  43:&lt;/span&gt;             &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum44" style="color: #606060"&gt;  44:&lt;/span&gt;             SubPropertyAccessor&amp;lt;Attribute&amp;gt;.CustomProperties.Add(textBox1.Text, aType);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum45" style="color: #606060"&gt;  45:&lt;/span&gt;             dataGridView1.Columns.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SubPropertyColumn { IndexedPropertyName = &lt;span style="color: #006080"&gt;&amp;quot;Properties&amp;quot;&lt;/span&gt;, PropertyIndex = textBox1.Text, HeaderText = textBox1.Text, ValueType = aType.FullName });&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum46" style="color: #606060"&gt;  46:&lt;/span&gt;             loadGrid();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum47" style="color: #606060"&gt;  47:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="CopyToClipboardOuter" &gt;&lt;div class="CopyToClipboardInner"&gt;&lt;a href="javascript:void(0);" title="View Plain" onclick="CopyToClipboard_ViewPlain(copyToClipboard200319f66a954592b09711aa4f568d73_338272);"&gt;View Plain&lt;/a&gt; &lt;/div&gt;&lt;/div&gt;
					&lt;script type="text/javascript"&gt;
						var copyToClipboard200319f66a954592b09711aa4f568d73_338272 = CopyToClipboard_Strip('        private void loadGrid() {\r\n            fContext.SubmitChanges();\r\n            var result = from aSong in fContext.Songs select aSong;\r\n            songBindingSource.DataSource = result;\r\n        }\r\n\r\n        private void button1_Click(object sender, EventArgs e) {\r\n            Type aType = typeof(string);\r\n\r\n            if (comboBox1.SelectedItem.ToString() == &amp;quot;Integer&amp;quot;) {\r\n                aType = typeof(int);\r\n            }\r\n            else if (comboBox1.SelectedItem.ToString() == &amp;quot;Double&amp;quot;) {\r\n                aType = typeof(double);\r\n            }\r\n            else if (comboBox1.SelectedItem.ToString() == &amp;quot;Date&amp;quot;) {\r\n                aType = typeof(DateTime);\r\n            }\r\n            \r\n            SubPropertyAccessor&amp;lt;Attribute&amp;gt;.CustomProperties.Add(textBox1.Text, aType);\r\n            dataGridView1.Columns.Add(new SubPropertyColumn { IndexedPropertyName = &amp;quot;Properties&amp;quot;, PropertyIndex = textBox1.Text, HeaderText = textBox1.Text, ValueType = aType.FullName });\r\n            loadGrid();\r\n        }');
					&lt;/script&gt;

&lt;p&gt;Most of the click handler for the button is concerned with getting a Type from the ComboBox.&amp;#160; The important stuff happens in lines 44 through 46.&amp;#160; On line 44 we add the CustomProperty to the SubPropertyAccessor.&amp;#160; Line 45 adds a column to the DataGridView to show the new CustomProperty.&amp;#160; Finally, on line 46, the DataGridView is reloaded.&amp;#160; This forces the grid to re-run the reflection on the bound data so that it will discover the new “Property” that was added.&lt;/p&gt;

&lt;h1&gt;Conclusion&lt;/h1&gt;

&lt;p&gt;There’s a lot of code that goes into presenting child data as part of a master object.&amp;#160; Fortunately, most of the code is done in generic classes.&amp;#160; This allows us to take advantage of this functionality without having to go through this exercise every time.&lt;/p&gt;

&lt;p&gt;The file attached to this article contains all of the source code for all of the classes I presented and the demo program.&amp;#160; The code changes significantly from part 1 and part 2.&amp;#160; The file attached to this part (part 3) contains all of the functionality discussed in all three parts.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;div class="wlWriterEditableSmartContent" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:fcb4c6f9-90a1-4aef-9356-3f31cc8bc7d3" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;p&gt;Source Code: &lt;a href="http://www.dogspots.com/pictures/PresentingDetailValuesasPartoftheMasterp_98CF/SubPropertyColumns.zip" target="_blank"&gt;SubPropertyColumns.zip (220 KB)&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description>
      <link>http://www.dogspots.com/DSBE/post/2009/09/04/Detail-Values-as-part-of-the-Master-part-3.aspx</link>
      <author>Bill</author>
      <comments>http://www.dogspots.com/DSBE/post/2009/09/04/Detail-Values-as-part-of-the-Master-part-3.aspx#comment</comments>
      <guid>http://www.dogspots.com/DSBE/post.aspx?id=94c09569-6fb5-4a6a-892a-cea1d4866bef</guid>
      <pubDate>Fri, 04 Sep 2009 15:39:22 -0500</pubDate>
      <category>.Net Programming</category>
      <dc:publisher>Bill</dc:publisher>
      <pingback:server>http://www.dogspots.com/DSBE/pingback.axd</pingback:server>
      <pingback:target>http://www.dogspots.com/DSBE/post.aspx?id=94c09569-6fb5-4a6a-892a-cea1d4866bef</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.dogspots.com/DSBE/trackback.axd?id=94c09569-6fb5-4a6a-892a-cea1d4866bef</trackback:ping>
      <wfw:comment>http://www.dogspots.com/DSBE/post/2009/09/04/Detail-Values-as-part-of-the-Master-part-3.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.dogspots.com/DSBE/syndication.axd?post=94c09569-6fb5-4a6a-892a-cea1d4866bef</wfw:commentRss>
    </item>
  </channel>
</rss>