<?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/"
	>

<channel>
	<title>Gonçalo Ferreira's Blog</title>
	<atom:link href="http://monxalo.110mb.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://monxalo.110mb.com/blog</link>
	<description>Thoughts &#38; tutorials about programming aspects and languages</description>
	<pubDate>Sun, 16 Aug 2009 23:08:57 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Binding a HashTable to a ComboBox [C#]</title>
		<link>http://monxalo.110mb.com/blog/?p=14</link>
		<comments>http://monxalo.110mb.com/blog/?p=14#comments</comments>
		<pubDate>Tue, 30 Dec 2008 21:07:17 +0000</pubDate>
		<dc:creator>Gonçalo Ferreira</dc:creator>
		
		<category><![CDATA[.NET CF]]></category>

		<category><![CDATA[.NET Framework]]></category>

		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://monxalo.110mb.com/blog/?p=14</guid>
		<description><![CDATA[On other day i was trying to use HashTable to display records in a combo box being the Key the Display Member and Value the ValueMember like so:
HashTable hash = new HashTable();
ComboBox ddlText = new ComboBox();

hash.Add(&#34;FirstKey&#34;, 1000);
hash.Add(&#34;SecondKey&#34;, 1005);            

ddlText.BeginUpdate();

ddlText.ValueMember = &#34;Value&#34;;
ddlText.DisplayMember = &#34;Key&#34;;
ddlText.DataSource = [...]]]></description>
			<content:encoded><![CDATA[<p>On other day i was trying to use HashTable to display records in a combo box being the Key the Display Member and Value the ValueMember like so:</p>
<pre class="brush: csharp;">HashTable hash = new HashTable();
ComboBox ddlText = new ComboBox();

hash.Add(&quot;FirstKey&quot;, 1000);
hash.Add(&quot;SecondKey&quot;, 1005);            

ddlText.BeginUpdate();

ddlText.ValueMember = &quot;Value&quot;;
ddlText.DisplayMember = &quot;Key&quot;;
ddlText.DataSource = hash;

ddlText.EndUpdate();</pre>
<p>But in order to bind an object to a ComboBox it has to implement IList or IListSource interface.</p>
<p>So i created a new class derived from HashTable implementing the IListSource interface:</p>
<pre class="brush: csharp;">public class EnhancedHashTable : Hashtable, IListSource
{
    public bool ContainsListCollection
    {
        get { return true; }
    }

    public IList GetList()
    {
        List list = new List();
        foreach (DictionaryEntry obj in this)
            list.Add(obj);

        return list;
    }
}</pre>
<p>Using a Dictionary&#8230;</p>
<pre class="brush: csharp;">public class EnhancedDictionary:Dictionary, IListSource
{
    public bool ContainsListCollection
    {
      get { return true; }
    }

    public IList GetList()
    {
        List &amp;gt; list = new List&amp;gt;();
        foreach (KeyValuePair entry in this)
             list.Add(entry);

        return list;
    }
}</pre>
<p><strong>UPDATE</strong>: Looks like there is a simpler solution, instead of implementing this class. You simply use .NET 2.0 BindingSource class.</p>
]]></content:encoded>
			<wfw:commentRss>http://monxalo.110mb.com/blog/?feed=rss2&amp;p=14</wfw:commentRss>
		</item>
		<item>
		<title>First post..</title>
		<link>http://monxalo.110mb.com/blog/?p=9</link>
		<comments>http://monxalo.110mb.com/blog/?p=9#comments</comments>
		<pubDate>Wed, 01 Oct 2008 22:39:28 +0000</pubDate>
		<dc:creator>Gonçalo Ferreira</dc:creator>
		
		<category><![CDATA[personal]]></category>

		<guid isPermaLink="false">http://monxalo.110mb.com/blog/?p=9</guid>
		<description><![CDATA[Here i am writing my first blog post.
The main reasons for creation of this blog are:

A chance to practice my english writing (which is very rusty).
Share knowlegde on the various IT tecnologies and programming Languages that i&#8217;ve gathered through out the years.
To share some personal thoughts and curious subjects.

Well, enough said.  On with the posts.. [...]]]></description>
			<content:encoded><![CDATA[<p>Here i am writing my first blog post.</p>
<p>The main reasons for creation of this blog are:</p>
<ul>
<li>A chance to practice my english writing (which is very rusty).</li>
<li>Share knowlegde on the various IT tecnologies and programming Languages that i&#8217;ve gathered through out the years.</li>
<li>To share some personal thoughts and curious subjects.</li>
</ul>
<p>Well, enough said.  On with the posts.. :).</p>
]]></content:encoded>
			<wfw:commentRss>http://monxalo.110mb.com/blog/?feed=rss2&amp;p=9</wfw:commentRss>
		</item>
	</channel>
</rss>
