<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Right-Click ListBox &#8211; Select Item</title>
	<atom:link href="http://blog.robgarrett.com/2006/04/05/right-click-listbox-select-item/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.robgarrett.com/2006/04/05/right-click-listbox-select-item/</link>
	<description>Software and Technology Tid-bits</description>
	<lastBuildDate>Mon, 09 Jan 2012 22:06:21 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: http://</title>
		<link>http://blog.robgarrett.com/2006/04/05/right-click-listbox-select-item/#comment-372</link>
		<dc:creator><![CDATA[http://]]></dc:creator>
		<pubDate>Tue, 19 Feb 2008 10:12:19 +0000</pubDate>
		<guid isPermaLink="false">/cs/blogs/software/archive/2006/04/05/1915.aspx#comment-372</guid>
		<description><![CDATA[Guess there are plenty of ways of doing this, easiest way i found was to send a left click before the right mouse button comes back up!

Private Declare Function SetCursorPos Lib &quot;user32&quot; (ByVal x As Long, ByVal Y As Long) As Long
Private Declare Sub mouse_event Lib &quot;user32&quot; (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Private Const MOUSEEVENTF_LEFTDOWN = &amp;H2
Private Const MOUSEEVENTF_LEFTUP = &amp;H4

Private Sub ListBox1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal Y As Single)
If Button = 2 Then
mouse_event MOUSEEVENTF_LEFTDOWN, 0&amp;, 0&amp;, 0&amp;, 0&amp;
mouse_event MOUSEEVENTF_LEFTUP, 0&amp;, 0&amp;, 0&amp;, 0&amp;
End If
End Sub

Like that! =]]]></description>
		<content:encoded><![CDATA[<p>Guess there are plenty of ways of doing this, easiest way i found was to send a left click before the right mouse button comes back up!</p>
<p>Private Declare Function SetCursorPos Lib &#8220;user32&#8243; (ByVal x As Long, ByVal Y As Long) As Long<br />
Private Declare Sub mouse_event Lib &#8220;user32&#8243; (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)<br />
Private Const MOUSEEVENTF_LEFTDOWN = &amp;H2<br />
Private Const MOUSEEVENTF_LEFTUP = &amp;H4</p>
<p>Private Sub ListBox1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal Y As Single)<br />
If Button = 2 Then<br />
mouse_event MOUSEEVENTF_LEFTDOWN, 0&amp;, 0&amp;, 0&amp;, 0&amp;<br />
mouse_event MOUSEEVENTF_LEFTUP, 0&amp;, 0&amp;, 0&amp;, 0&amp;<br />
End If<br />
End Sub</p>
<p>Like that! =]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin Dearing</title>
		<link>http://blog.robgarrett.com/2006/04/05/right-click-listbox-select-item/#comment-371</link>
		<dc:creator><![CDATA[Justin Dearing]]></dc:creator>
		<pubDate>Wed, 12 Dec 2007 16:03:17 +0000</pubDate>
		<guid isPermaLink="false">/cs/blogs/software/archive/2006/04/05/1915.aspx#comment-371</guid>
		<description><![CDATA[Rob,

I prefer this version it allows you to wire it to multiple listboxes.


        private void listBox_MouseDown(object sender, MouseEventArgs e)
        {
            ListBox lst = (ListBox) sender;
            // Select item if right click.
            if (MouseButtons.Right == e.Button)
            {
                Point pt = new Point(e.X, e.Y);
                lst.SelectedIndex = lst.IndexFromPoint(pt);
            }
        }

Generally I prefer the &quot;SenderType foo = (SenderType) sender;&quot; pattern as opposed to calling the item by its class member name in events.]]></description>
		<content:encoded><![CDATA[<p>Rob,</p>
<p>I prefer this version it allows you to wire it to multiple listboxes.</p>
<p>        private void listBox_MouseDown(object sender, MouseEventArgs e)<br />
        {<br />
            ListBox lst = (ListBox) sender;<br />
            // Select item if right click.<br />
            if (MouseButtons.Right == e.Button)<br />
            {<br />
                Point pt = new Point(e.X, e.Y);<br />
                lst.SelectedIndex = lst.IndexFromPoint(pt);<br />
            }<br />
        }</p>
<p>Generally I prefer the &#8220;SenderType foo = (SenderType) sender;&#8221; pattern as opposed to calling the item by its class member name in events.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: http://</title>
		<link>http://blog.robgarrett.com/2006/04/05/right-click-listbox-select-item/#comment-370</link>
		<dc:creator><![CDATA[http://]]></dc:creator>
		<pubDate>Mon, 08 May 2006 14:06:00 +0000</pubDate>
		<guid isPermaLink="false">/cs/blogs/software/archive/2006/04/05/1915.aspx#comment-370</guid>
		<description><![CDATA[Sweet--thanks for posting the example.]]></description>
		<content:encoded><![CDATA[<p>Sweet&#8211;thanks for posting the example.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

