<?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>Dot Net Thoughts &#187; Dropdown</title>
	<atom:link href="http://www.dotnetthoughts.net/tag/dropdown/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dotnetthoughts.net</link>
	<description>thoughts about .Net, WPF, Sharepoint, Javascript and more.</description>
	<lastBuildDate>Wed, 28 Jul 2010 09:59:26 +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>Color Picker Dropdown using C#</title>
		<link>http://www.dotnetthoughts.net/2009/10/15/color-picker-dropdown-using-c/</link>
		<comments>http://www.dotnetthoughts.net/2009/10/15/color-picker-dropdown-using-c/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 04:05:52 +0000</pubDate>
		<dc:creator>Anuraj P</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[Color Picker]]></category>
		<category><![CDATA[Drawing]]></category>
		<category><![CDATA[Drawmode]]></category>
		<category><![CDATA[Dropdown]]></category>
		<category><![CDATA[VB.Net]]></category>
		<category><![CDATA[Windows Forms]]></category>

		<guid isPermaLink="false">http://www.dotnetthoughts.net/?p=527</guid>
		<description><![CDATA[While playing around one of hobby project, I found there is a nice color picker dropdown available in WordPad, for setting the font color. I was using Windows Color Dialog. So I thought of implementing a WordPad like color picker. And I think I almost readed my goal. I need to try this in the [...]]]></description>
			<content:encoded><![CDATA[<p>While playing around one of hobby project, I found there is a nice color picker dropdown available in WordPad, for setting the font color. I was using Windows </p>
<p>Color Dialog. So I thought of implementing a WordPad like color picker. And I think I almost readed my goal. I need to try this in the Toolstrip dropdown too.</p>
<pre class="brush: csharp;">
//On the Form load I am loading the colors to the Dropdown.
//You can also bind the p to the Dropdown.
Type t = typeof(Color);
PropertyInfo[] p = t.GetProperties();
foreach (PropertyInfo item in p)
{
    if (item.PropertyType.FullName.Equals(&quot;System.Drawing.Color&quot;, StringComparison.CurrentCultureIgnoreCase))
    {
        this.comboBox1.Items.Add(item.Name);
    }
}
</pre>
<p>And I set the Dropdown&#8217;s DrawMode property to &#8220;OwnerDrawFixed&#8221;. And in the DrawItem event of the Dropdown I wrote the code.</p>
<pre class="brush: csharp;">
if (e.Index != -1)
{
    e.DrawBackground();
    e.Graphics.FillRectangle(GetCurrentBrush(comboBox1.Items[e.Index].ToString()), e.Bounds);
    Font f = comboBox1.Font;
    e.Graphics.DrawString(comboBox1.Items[e.Index].ToString(), f, Brushes.Black, e.Bounds, StringFormat.GenericDefault);
    e.DrawFocusRectangle();
}
</pre>
<p>And the GetCurrentBrush() function returns the Brush for painting the rectangle. You can write the code in the DrawItem event too, but initialy I thought about setting the font color using the same color. But later that idea changed.</p>
<pre class="brush: csharp;">
private Brush GetCurrentBrush(string colorName)
{
    return new SolidBrush(Color.FromName(colorName));
}
</pre>
<p>One issue I found in this code is, for black color, I can&#8217;t see the color name. And here is the screenshot of Color Picker Dropdown running on my machine.</p>
<div id="attachment_529" class="wp-caption alignnone" style="width: 285px"><img src="http://www.dotnetthoughts.net/wp-content/uploads/2009/10/color_dropdown.PNG" alt="Color Picker Dropdown screenshot" title="Color Picker Dropdown screenshot" width="275" height="385" class="size-full wp-image-529" /><p class="wp-caption-text">Color Picker Dropdown screenshot</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.dotnetthoughts.net/2009/10/15/color-picker-dropdown-using-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Clearing combobox items using javascript</title>
		<link>http://www.dotnetthoughts.net/2007/05/23/clearing-combobox-items-using-javascript/</link>
		<comments>http://www.dotnetthoughts.net/2007/05/23/clearing-combobox-items-using-javascript/#comments</comments>
		<pubDate>Wed, 23 May 2007 04:57:11 +0000</pubDate>
		<dc:creator>Anuraj P</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Combobox]]></category>
		<category><![CDATA[Dropdown]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://anuraj.wordpress.com/2007/05/23/clearing-combobox-items-using-javascript/</guid>
		<description><![CDATA[I already posted some code to add and read values from dropdown lists using Javascript. Sometimes we require to reset the items to zero or need to clear the items in the dropdown list. Here is a simple code snippet which will reset the dropdown items. function clearDropdown(dropdown) { var mycombo =document.getElementById(dropdown); mycombo.options.length = 0; [...]]]></description>
			<content:encoded><![CDATA[<p>I already <a href="http://www.dotnetthoughts.net/2007/05/11/adding-and-reading-values-from-combo-box-using-javascript/">posted</a> some code to add and read values from dropdown lists using Javascript. Sometimes we require to reset the items to zero or need to clear the items in the dropdown list. Here is a simple code snippet which will reset the dropdown items.</p>
<pre class="brush: jscript;">
function clearDropdown(dropdown)
{
var mycombo =document.getElementById(dropdown);
mycombo.options.length = 0;
return(false);
}
</pre>
<p>And you can use this function like this</p>
<pre class="brush: xml;">
&lt;button onclick=&quot;javascript:clearDropdown('myoptions')&quot;&gt;Reset Options&lt;/button&gt;
</pre>
<p>Where myoptions is the dropdown to clear.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dotnetthoughts.net/2007/05/23/clearing-combobox-items-using-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
