﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » .NET Forums » General .NET Discussion  » How to implement shortcut keys on toolstripbutton</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Sat, 30 May 2026 20:55:48 GMT</lastBuildDate><ttl>20</ttl><item><title>How to implement shortcut keys on toolstripbutton</title><link>http://forum.strataframe.net/FindPost15151.aspx</link><description>I can't figure out how to set a keyboard shortcut on a ToolstripButton (I'm assuming that there is an easy way), so the user can use Clt-S to save for example.&lt;br&gt;
&lt;br&gt;
So, is there an easy way to do this?  Or do I have to do this the hard way (capturing keyboard input, yada, yada)?&lt;br&gt;
&lt;br&gt;
Thanks!</description><pubDate>Tue, 25 Mar 2008 20:32:47 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: How to implement shortcut keys on toolstripbutton</title><link>http://forum.strataframe.net/FindPost15171.aspx</link><description>Cool :)</description><pubDate>Tue, 25 Mar 2008 20:32:47 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: How to implement shortcut keys on toolstripbutton</title><link>http://forum.strataframe.net/FindPost15167.aspx</link><description>Ahhhhh...the light bulb went off.  I get it. Thanks, that does make sense!</description><pubDate>Tue, 25 Mar 2008 17:33:53 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: How to implement shortcut keys on toolstripbutton</title><link>http://forum.strataframe.net/FindPost15165.aspx</link><description>Instead of overriding it at the toolstrip or toolstripbutton level, just add the logic in the form or user control that the toolstrip resides in.&amp;nbsp; This way you only have to override the ProcessCmdKey method on the form versus worrying about this in the toolstrip...this is what I generally do and it makes life a lot easier :)</description><pubDate>Tue, 25 Mar 2008 17:26:34 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: How to implement shortcut keys on toolstripbutton</title><link>http://forum.strataframe.net/FindPost15163.aspx</link><description>OK, I'm missing something. :blush:&lt;br&gt;
&lt;br&gt;
I don't know how to override the ProcessCmdKey method on the toolstripbutton outside of subclassing it.  How do I do it within the form (for example)?  &lt;br&gt;</description><pubDate>Tue, 25 Mar 2008 17:24:36 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: How to implement shortcut keys on toolstripbutton</title><link>http://forum.strataframe.net/FindPost15159.aspx</link><description>[quote]&lt;TABLE cellSpacing=0 cellPadding=0 width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class=smalltxt vAlign=top&gt;&lt;SPAN id=ctl02_ctlTopic_ctlPanelBar_ctlTopicsRepeater_ctl08_lblFullMessage&gt;Thanks Trent. I'm assuming this means I'd need to sub-class ToolstripButton, right?&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;[/quote]&lt;/P&gt;&lt;P&gt;You could, or just add this logic on the form/user control/etc that you want the Ctrl+S to work.&amp;nbsp; You can do the other and create your own type editor, etc. but that is way more work than it is worth...I would just do the other.</description><pubDate>Tue, 25 Mar 2008 14:33:09 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: How to implement shortcut keys on toolstripbutton</title><link>http://forum.strataframe.net/FindPost15157.aspx</link><description>Thanks Trent.  I'm assuming this means I'd need to sub-class ToolstripButton, right?  If I do that, then I'll need to either manually add buttons via code or manually update the designer file to use my sub-classed button, or is there some other way get a sub-classed toolstrip item into a toolstrip?</description><pubDate>Tue, 25 Mar 2008 10:53:46 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: How to implement shortcut keys on toolstripbutton</title><link>http://forum.strataframe.net/FindPost15152.aspx</link><description>Unfortuately a toolstrip button doesn't have the ShortcutKey that a menustrip item does...however, you can do this pretty easy.&amp;nbsp; Just override the ProcessCmdKey method and add your logic:&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;/P&gt;&lt;P&gt;Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; '-- Check for unique keystrokes&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Select Case keyData&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Case Keys.Control Or Keys.S&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '-- Perform save logic&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Select&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return MyBase.ProcessCmdKey(msg, keyData)&lt;BR&gt;End Function[/codesnippet]</description><pubDate>Mon, 24 Mar 2008 19:30:41 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>