Click here to Skip to main content
15,897,187 members
Articles / Programming Languages / C#

Customized Display of Collection Data in a PropertyGrid

Rate me:
Please Sign up or sign in to vote.
4.92/5 (165 votes)
30 Jun 200310 min read 1.1M   13.5K   388  
PropertyGrid is widely used to display an object's properties and values
In this article, I will explore an answer to two questions. How is it possible that an array provides its contained objects to the PropertyGrid as if they were properties? Furthermore, the names of the objects contained in the array are displayed with its sequence numbers ( [0],[1],...). The second question is how to customize so that more meaningful data is displayed instead of sequence numbers? We will also develop a solution.
<?xml version="1.0" encoding="utf-8" ?>
<root>
	<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
		<xsd:element name="root" msdata:IsDataSet="true">
			<xsd:complexType>
				<xsd:choice maxOccurs="unbounded">
					<xsd:element name="data">
						<xsd:complexType>
							<xsd:sequence>
								<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
								<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
							</xsd:sequence>
							<xsd:attribute name="name" type="xsd:string" />
							<xsd:attribute name="type" type="xsd:string" />
							<xsd:attribute name="mimetype" type="xsd:string" />
						</xsd:complexType>
					</xsd:element>
					<xsd:element name="resheader">
						<xsd:complexType>
							<xsd:sequence>
								<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
							</xsd:sequence>
							<xsd:attribute name="name" type="xsd:string" use="required" />
						</xsd:complexType>
					</xsd:element>
				</xsd:choice>
			</xsd:complexType>
		</xsd:element>
	</xsd:schema>
	<resheader name="ResMimeType">
		<value>text/microsoft-resx</value>
	</resheader>
	<resheader name="Version">
		<value>1.0.0.0</value>
	</resheader>
	<resheader name="Reader">
		<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
	</resheader>
	<resheader name="Writer">
		<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
	</resheader>
	<data name="FirstName">
		<value>Vorname</value>
	</data>
	<data name="LastName">
		<value>Nachname</value>
	</data>
	<data name="FirstNameDescription">
		<value>Beschreibung für die Eigenschaft Vorname</value>
	</data>
	<data name="LastNameDescription">
		<value>Beschreibung für die Eigenschaft Nachname</value>
	</data>
	<data name="Age">
		<value>Alter</value>
	</data>
	<data name="AgeDescription">
		<value>Beschreibung für die Eigenschaft Alter</value>
	</data>
	<data name="Required">
		<value>Erforderliche Angaben</value>
	</data>
	<data name="Optional">
		<value>Ergänzende Angaben</value>
	</data>
	<data name="Department">
		<value>ZZZ</value>
	</data>
</root>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


Written By
Web Developer
Germany Germany
For ten years I worked as a senior consultant, coach, lead architect and project lead for several consulting companies.
Currently I work as a system architect for Zuehlke Engineering GmbH based in Frankfurt.
You can find a detailed resume here.

Comments and Discussions