<?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>Solomon &#187; Auto Complete ComboBox</title>
	<atom:link href="http://www.ms.oyangudi.com/blog/tag/auto-complete-combobox/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ms.oyangudi.com/blog</link>
	<description>from Oyangudi...</description>
	<lastBuildDate>Tue, 18 Oct 2011 02:38:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Auto Complete ComboBox &#8211; VB.NET Windows Forms</title>
		<link>http://www.ms.oyangudi.com/blog/vbnet/auto-complete-combobox-vb-net-windows-forms/</link>
		<comments>http://www.ms.oyangudi.com/blog/vbnet/auto-complete-combobox-vb-net-windows-forms/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 04:40:15 +0000</pubDate>
		<dc:creator>Solomon</dc:creator>
				<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Auto Complete ComboBox]]></category>

		<guid isPermaLink="false">http://www.ms.oyangudi.com/blog/?p=27</guid>
		<description><![CDATA[Download source files &#8211; 17.6 Kb Download demo project &#8211; 9.08 Kb Introduction This is a simple code snippet which is used to make an Auto Complete ComboBox. Using the code Usage: Call the subroutine from within the ComboBox&#8217;s KeyPress event handler. cb &#8211; ComboBox used to make the Auto Complete ComboBox. e &#8211; System.Windows.Forms.KeyPressEventArgs [...]]]></description>
			<content:encoded><![CDATA[<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/vbnet/auto-complete-combobox-vb-net-windows-forms/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/vbnet/auto-complete-combobox-vb-net-windows-forms/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="Auto Complete ComboBox &ndash; VB.NET Windows Forms" data-url="http://www.ms.oyangudi.com/blog/vbnet/auto-complete-combobox-vb-net-windows-forms/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
<ul>
<li><a href="http://www.ms.oyangudi.com/blog/wp-content/uploads/AutoCompleteComboBoxVB.NETWindowsForms_1485F/Auto_Complele_ComboBox_src_vb.zip">Download source files &#8211; 17.6 Kb</a> </li>
<li><a href="http://www.ms.oyangudi.com/blog/wp-content/uploads/AutoCompleteComboBoxVB.NETWindowsForms_1485F/Auto_Complele_ComboBox_demo_vb.zip">Download demo project &#8211; 9.08 Kb</a> </li>
</ul>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="AutoComplete" border="0" alt="AutoComplete" src="http://www.ms.oyangudi.com/blog/wp-content/uploads/AutoCompleteComboBoxVB.NETWindowsForms_1485F/AutoComplete.gif" width="320" height="288" /> </p>
</p>
<h4>Introduction</h4>
<p>This is a simple code snippet which is used to make an <b>Auto Complete ComboBox.</b> </p>
<h4>Using the code</h4>
<p><b>Usage:</b> Call the subroutine from within the ComboBox&#8217;s <code>KeyPress</code> event handler. </p>
<div>
<pre class="brush: vb; title: ; notranslate">

AutoComplete(ByRef cb As ComboBox, ByVal e As System.Windows.Forms.KeyPressEventArgs, Optional ByVal blnLimitToList As Boolean = False)
</pre>
</div>
<ul>
<li><code>cb</code> &#8211; ComboBox used to make the Auto Complete ComboBox. </li>
<li><code>e</code> &#8211; <code>System.Windows.Forms.KeyPressEventArgs</code> used to handle the keyboard inputs. </li>
<li><code>blnLimitToList</code> &#8211; Optional Boolean value indicating whether the user input is limited to the list values or not. </li>
</ul>
<h4>Code</h4>
<div>
<pre class="brush: vb; title: ; notranslate">

    ' AutoComplete
    Public Sub AutoComplete(ByRef cb As ComboBox, ByVal e As System.Windows.Forms.KeyPressEventArgs, Optional ByVal blnLimitToList As Boolean = False)
        Dim strFindStr As String

        If e.KeyChar = Chr(8) Then  'Backspace
            If cb.SelectionStart &lt;= 1 Then
                cb.Text = &quot;&quot;
                Exit Sub
            End If
            If cb.SelectionLength = 0 Then
                strFindStr = cb.Text.Substring(0, cb.Text.Length - 1)
            Else
                strFindStr = cb.Text.Substring(0, cb.SelectionStart - 1)
            End If
        Else
            If cb.SelectionLength = 0 Then
                strFindStr = cb.Text &amp; e.KeyChar
            Else
                strFindStr = cb.Text.Substring(0, cb.SelectionStart) &amp; e.KeyChar
            End If
        End If

        Dim intIdx As Integer = -1

        ' Search the string in the Combo Box List.
        intIdx = cb.FindString(strFindStr)

        If intIdx &lt;&gt; -1 Then ' String found in the List.
            cb.SelectedText = &quot;&quot;
            cb.SelectedIndex = intIdx
            cb.SelectionStart = strFindStr.Length
            cb.SelectionLength = cb.Text.Length
            e.Handled = True
        Else
            If blnLimitToList = True Then
                e.Handled = True
            Else
                e.Handled = False
            End If
        End If
    End Sub
</pre>
</div>
<pre>&#160;</pre>
<h4>History</h4>
<ul>
<li>Released on July 30<sup>th</sup>, 2005. </li>
</ul>
<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/vbnet/auto-complete-combobox-vb-net-windows-forms/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/vbnet/auto-complete-combobox-vb-net-windows-forms/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="Auto Complete ComboBox &ndash; VB.NET Windows Forms" data-url="http://www.ms.oyangudi.com/blog/vbnet/auto-complete-combobox-vb-net-windows-forms/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ms.oyangudi.com/blog/vbnet/auto-complete-combobox-vb-net-windows-forms/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Auto Complete ComboBox &#8211; C# Windows Forms</title>
		<link>http://www.ms.oyangudi.com/blog/csharp/auto-complete-combobox-c-windows-forms/</link>
		<comments>http://www.ms.oyangudi.com/blog/csharp/auto-complete-combobox-c-windows-forms/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 04:38:37 +0000</pubDate>
		<dc:creator>Solomon</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Auto Complete ComboBox]]></category>

		<guid isPermaLink="false">http://www.ms.oyangudi.com/blog/?p=26</guid>
		<description><![CDATA[Download source files &#8211; 8.50 Kb Download demo project &#8211; 11.0 Kb Introduction This is a simple code snippet which is used to make an Auto Complete ComboBox. Using the code Usage: Call the function AutoComplete from within the ComboBox&#8217;s KeyPress event handler. Code History Released on November 8th 2006.]]></description>
			<content:encoded><![CDATA[<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/csharp/auto-complete-combobox-c-windows-forms/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/csharp/auto-complete-combobox-c-windows-forms/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="Auto Complete ComboBox &ndash; C# Windows Forms" data-url="http://www.ms.oyangudi.com/blog/csharp/auto-complete-combobox-c-windows-forms/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
<ul>
<li><a href="http://www.ms.oyangudi.com/blog/wp-content/uploads/AutoCompleteComboBoxCWindowsForms_14763/AutoCompleteComboBox_src_cs.zip">Download source files &#8211; 8.50 Kb</a> </li>
<li><a href="http://www.ms.oyangudi.com/blog/wp-content/uploads/AutoCompleteComboBoxCWindowsForms_14763/AutoCompleteComboBox_demo_cs.zip">Download demo project &#8211; 11.0 Kb</a> </li>
</ul>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="AutoComplete" border="0" alt="AutoComplete" src="http://www.ms.oyangudi.com/blog/wp-content/uploads/AutoCompleteComboBoxCWindowsForms_14763/AutoComplete.gif" width="320" height="288" /> </p>
<h4>Introduction</h4>
<p>This is a simple code snippet which is used to make an <b>Auto Complete ComboBox</b>. </p>
<h4>Using the code</h4>
<p><b>Usage:</b> Call the function AutoComplete from within the ComboBox&#8217;s KeyPress event handler. </p>
<div>
<pre class="brush: csharp; title: ; notranslate">

AutoComplete(ComboBox cb, System.Windows.Forms.KeyPressEventArgs e, bool blnLimitToList)
</pre>
</div>
<h4>Code</h4>
<div>
<pre class="brush: csharp; title: ; notranslate">

        /// &lt;summary&gt;
        /// AutoComplete
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;cb&quot;&gt;ComboBox&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;KeyPressEventArgs&lt;/param&gt;
        /// &lt;param name=&quot;blnLimitToList&quot;&gt;Limit to List&lt;/param&gt;
		public void AutoComplete(ComboBox cb, System.Windows.Forms.KeyPressEventArgs e, bool blnLimitToList)
		{
			string strFindStr = &quot;&quot;;

			if (e.KeyChar == (char)8)
			{
				if (cb.SelectionStart &lt;= 1)
				{
					cb.Text = &quot;&quot;;
					return;
				}

				if (cb.SelectionLength == 0)
					strFindStr = cb.Text.Substring(0, cb.Text.Length - 1);
						else
					strFindStr = cb.Text.Substring(0, cb.SelectionStart - 1);
					}
			else
			{
				if (cb.SelectionLength == 0)
					strFindStr = cb.Text + e.KeyChar;
				else
					strFindStr = cb.Text.Substring(0, cb.SelectionStart) + e.KeyChar;
			}

			int intIdx = -1;

			// Search the string in the ComboBox list.

			intIdx = cb.FindString(strFindStr);

			if (intIdx != -1)
			{
				cb.SelectedText = &quot;&quot;;
				cb.SelectedIndex = intIdx;
				cb.SelectionStart = strFindStr.Length;
				cb.SelectionLength = cb.Text.Length;
				e.Handled = true;
			}
			else
			{
				e.Handled = blnLimitToList;
			}
		}
</pre>
</div>
<h4>History</h4>
<p>Released on November 8th 2006. </p>
<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/csharp/auto-complete-combobox-c-windows-forms/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/csharp/auto-complete-combobox-c-windows-forms/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="Auto Complete ComboBox &ndash; C# Windows Forms" data-url="http://www.ms.oyangudi.com/blog/csharp/auto-complete-combobox-c-windows-forms/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ms.oyangudi.com/blog/csharp/auto-complete-combobox-c-windows-forms/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

