StrataFrame Forum
Back
Login
Login
Home
»
StrataFrame Application Framework - V1
»
WinForms (How do I?)
»
Setting focus to Button in a ThemedToolStrip
Setting focus to Button in a ThemedToolStrip
Post Reply
Like
0
Setting focus to Button in a ThemedToolStrip
View
Flat Ascending
Flat Descending
Threaded
Options
Subscribe to topic
Print This Topic
RSS Feed
Goto Topics Forum
Author
Message
Ger Cannoll
Ger Cannoll
posted 11 Years Ago
ANSWER
Topic Details
Share Topic
Group: StrataFrame Users
Posts: 430,
Visits: 507
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
I dont seem to be able to get an option to do this
Reply
Like
0
StrataFrame Team
S
StrataFrame Team
posted 11 Years Ago
ANSWER
Post Details
Share Post
S
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
.NET doesn't do this for you by default. It takes a little work, but you can get it done. Basically, you want to set the System.Windows.Forms.Form.AcceptButton property to your toolstrip button. The AcceptButton property accepts an IButtonControl object, but ToolStripButton does not implement it by default. 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.
When you subclass the ToolStripButton, you cannot set it through the designer. The ToolStrip designer only knows about the ToolStripButton class, not your subclass. You will need to create the button and add it to the ToolStrip in code somewhere in the constructor of your form. 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.
Reply
Like
1
GO
Merge Selected
Merge into selected topic...
Merge into merge target...
Merge into a specific topic ID...
Open Merge
Post Reply
Like
0
Similar Topics
Post Quoted Reply
Reading This Topic
Login
Login
Remember Me
Reset Password
Resend Validation Email
Login
Explore
Messages
Mentions
Search