﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WinForms (How do I?)  » Setting focus to Button in a ThemedToolStrip</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 16:21:44 GMT</lastBuildDate><ttl>20</ttl><item><title>Setting focus to Button in a ThemedToolStrip</title><link>http://forum.strataframe.net/FindPost31876.aspx</link><description>I want to set focus to a Button in a ThemedToolstrip, so that when the form loads, it will be enabled and just need to hit the Enter Key&lt;br/&gt;&lt;br/&gt;I dont seem to be able to get an option to do this</description><pubDate>Tue, 26 Feb 2013 10:03:04 GMT</pubDate><dc:creator>Ger Cannoll</dc:creator></item><item><title>RE: Setting focus to Button in a ThemedToolStrip</title><link>http://forum.strataframe.net/FindPost31877.aspx</link><description>.NET doesn't do this for you by default. &amp;nbsp;It takes a little work, but you can get it done. &amp;nbsp;Basically, you want to set the System.Windows.Forms.Form.AcceptButton property to your toolstrip button. &amp;nbsp;The AcceptButton property accepts an IButtonControl object, but ToolStripButton does not implement it by default. &amp;nbsp;If you subclass ToolStripButton and implement that interface (it's simple, just 3 members), you can then set it as the AcceptButton on the form, and the form will call PerformClick() on it when the user hits enter, even if the button doesn't have focus. &amp;nbsp;&lt;br/&gt;&lt;br/&gt;&lt;div&gt;When you subclass the ToolStripButton, you cannot set it through the designer. The ToolStrip designer only knows about the ToolStripButton class, not your subclass. &amp;nbsp;You will need to create the button and add it to the ToolStrip in code somewhere in the constructor of your form. &amp;nbsp;I think you'll need to set the AcceptButton in code as well, because the TypeEditor for it won't be able to see your custom button.</description><pubDate>Tue, 26 Feb 2013 10:03:04 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item></channel></rss>