<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>FlickDotNet.de - Holger&#039;s Take on Software Development &#187; XtraTreeList</title>
	<atom:link href="http://www.flickdotnet.de/index.php/tags/xtratreelist/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.flickdotnet.de</link>
	<description>Opinions, Reviews, Tutorials for Software Developers - Apple iOS, Microsoft .NET and Delphi</description>
	<lastBuildDate>Tue, 26 Jul 2011 17:32:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>XtraTreeList: Which element in my IList is selected?</title>
		<link>http://www.flickdotnet.de/index.php/2008/08/xtratreelist-which-element-in-my-ilist-is-selected/</link>
		<comments>http://www.flickdotnet.de/index.php/2008/08/xtratreelist-which-element-in-my-ilist-is-selected/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 14:20:22 +0000</pubDate>
		<dc:creator>holger</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Winform]]></category>
		<category><![CDATA[XtraTreeList]]></category>

		<guid isPermaLink="false">http://www.flickdotnet.de/?p=133</guid>
		<description><![CDATA[Let us look at some common means that different frameworks use to deliver a result to this question. As I mentioned before, I mostly used the standard .NET components or VCL controls. Data-based VCL controls can be bound to TDataSource (and derivatives due to polymorphism). If an item is being selected, the cursor in the [...]]]></description>
			<content:encoded><![CDATA[<p>Let us look at some common means that different frameworks use to deliver a result to this question.</p>
<p>As I mentioned before, I mostly used the standard .NET components or VCL controls. Data-based VCL controls can be bound to TDataSource (and derivatives due to polymorphism). If an item is being selected, the cursor in the source moves accordingly. Thus, there is no difficulty to determine which row in the dataset it selected as it is the current row of the dataset. </p>
<p>.NET uses a different system of databinding, especially as you can bind &#8211; as I tend to say, but please do not take it literally &#8211; anything to a control. It is very flexible in that regard. Let us not even consider the possibilities that arise due to WPF. </p>
<p>In my last blog post I bound an XtraTreeList to a datasource of the datatype List<>. Any .NET standard control implements some kind of CurrencyHandler, which I find a bit too complex to use for a simple &#8220;Tell me what is selected&#8221;. Thus, I like ECO very much that it delivers a means to determine a selected object in a list of objects via its CurrencyManagerHandle. It always points to the selected object and you have a reference you can work with.</p>
<p>Now to XtraTreeList. In my example it is bound to a datasource that implements the IList interface. From reading the documentation I found out that it is very important that there is a difference between focused and selected row. Be aware that these terms play a major role which also depends on the fact if your list allows multi-selection or not. </p>
<p>In this case, we do not have multi-selection, thus the property we are interested in is called FocusedNode. The object instance we get as a return value is not of the element type of the list we bound to. Very unlucky. So, we need to investigate the return type. IntelliSense immediately offers &#8220;Id&#8221; as a property that looks like we could use.</p>
<p>In my example I query it like this:</p>
<p>    int id = trFolders.FocusedNode.Id;</p>
<p>The Id designates the index of the element inside the element list we bound to. Excellent. I wonder why it is not named accordingly, but it is something I can live with <img src='http://www.flickdotnet.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  </p>
<p>This leads to my final implementation to get the selected FolderTreeItem in my example:</p>
<p>    public FolderTreeItem SelectedFolderTreeItem<br />
    {<br />
         get<br />
         {<br />
              int id = trFolders.FocusedNode.Id;<br />
              FolderTreeItem selectedItem = dataSource[id];<br />
              return selectedItem;<br />
          }<br />
    }</p>
<p>I hope this will be helpful for people as all the examples delivered with XtraTreeView I could find do not deliver an example for this. I am not saying they do not exist, but they were too hard for me to find. Furthermore, I am still used to the other means to get the selected object and can be considered &#8220;user at a basic stage&#8221; regarding the DX control set.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flickdotnet.de/index.php/2008/08/xtratreelist-which-element-in-my-ilist-is-selected/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XtraTreeView: Display a tree structure easily (Binding to an IList data source)</title>
		<link>http://www.flickdotnet.de/index.php/2008/07/xtratreeview-display-a-tree-structure-easily-binding-to-an-ilist-data-source/</link>
		<comments>http://www.flickdotnet.de/index.php/2008/07/xtratreeview-display-a-tree-structure-easily-binding-to-an-ilist-data-source/#comments</comments>
		<pubDate>Thu, 31 Jul 2008 21:28:47 +0000</pubDate>
		<dc:creator>holger</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Winform]]></category>
		<category><![CDATA[XtraTreeList]]></category>

		<guid isPermaLink="false">http://www.flickdotnet.de/?p=112</guid>
		<description><![CDATA[Today I found yet another example that most blog posts do not need to describe something extremely complicated to be helpful. I was talking to a co-worker at University about the fact that the standard TreeView control that is being delivered with the .NET libraries is a bit unusual to use. Especially, binding data to [...]]]></description>
			<content:encoded><![CDATA[<p>Today I found yet another example that most blog posts do not need to describe something extremely complicated to be helpful. I was talking to a co-worker at University about the fact that the standard TreeView control that is being delivered with the .NET libraries is a bit unusual to use. Especially, binding data to it is not an easy thing to do.</p>
<p>I immediately thought of XtraTreeView by DevExpress, which is a very complex control, but also yields excellent results without looking at it in great detail to get &#8220;some neat results and fast&#8221;.</p>
<p>For example, I had the task to display the folder structure of an Outlook data file. With the standard control you would need to add the nodes recursively, but with XtraTreeView you can data bind to a simple generic list structure. To be precise: List&lt;myClass&gt;.</p>
<p>The next screenshot shows the result you get by simply assigning the list to the data source property of the XtraTreeGrid:</p>
<p style="text-align: center;"><img class="size-full wp-image-111 aligncenter" title="Screenshot of Demo Application" src="http://www.flickdotnet.de/wp-content/uploads/2008/07/xtratree.png" alt="" width="593" height="479" /></p>
<p>You might ask &#8220;How can a tree be built from a one-dimensional list/array of objects?&#8221;. If I remember correctly, the VirtualTreeGrid component by Mike Lischke offers the same approach if I am not mistaken. I emphasize: If I remember correctly.</p>
<p>The hierarchy is being built using a property as Id which identifies every object uniquely and another property which denotes the parent object using this very Id.</p>
<p>This is the object that I want to display:</p>
<p>public class FolderTreeItem<br />
{<br />
    public int Id { get; set; }<br />
    public int ParentId { get; set; }<br />
    public string NameShort { get; set; }<br />
    public string NameFull { get; set; }<br />
    public bool IsContactFolder<br />
    {<br />
        get<br />
        {<br />
            return isContactFolder();<br />
        }<br />
    }</p>
<p>&#8230;</p>
<p>Note that all the information I want to display is stored in public properties. I also define two integer properties for the Id and ParentId.</p>
<p>My datasource consists of a generic list of these objects. If I assigned the datasource to a default XtraTreeList, just dropped on the form, it would be a list. No hierarchy would be created.</p>
<p>The XtraTreeList instance has two properties which one needs to adjust for the data source being used. The properties are called KeyFieldName and ParentFieldName. You may guess what values you have to enter there. KeyFieldName is being set to &#8220;Id&#8221; and ParentFieldName has to be &#8220;ParentId&#8221;.</p>
<p>That&#8217;s it.</p>
<p>After this giant modification XtraTreeList is able to display the list as a hierarchy. Not a lot of &#8220;work&#8221; was it?</p>
<p>The click event of the button which retrieves looks like this:</p>
<p>private void simpleButton1_Click(object sender, EventArgs e)<br />
{<br />
    ConnectionWrapper wrapper = new ConnectionWrapper();<br />
    dataSource = wrapper.TreeItems;<br />
    trFolders.DataSource = dataSource;<br />
}</p>
<p>Due to the encapsulation of the Outlook part in a separate class and the use of a data structure which is prepared for the XtraTreeList the work to create a user-friendly GUI is minimal.</p>
<p><em>XtraTreeList is a component in the Winform component pack for the Microsoft .NET platform by DevExpress. More information on <a href="http://www.devexpres.com">DevExpress.com.</a></em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flickdotnet.de/index.php/2008/07/xtratreeview-display-a-tree-structure-easily-binding-to-an-ilist-data-source/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

