Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
| Search | Today's Posts | Mark Forums Read
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 10th, 2003, 09:43 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default accelerator keys and the tab control

I have a problem with providing accelerator keys for buttons on a tab control.

Keeping it simple to save me typing, if I have a tab control with, say, 3 tabs and each tab has an Update button on it, how can I make it so that the user can hit <alt>U and that will fire the click event of the Update button on the tab that has focus. Needless to say each of the buttons has to have the caption [u]U</u>pdate.

Anyone got any neat tricks for this? Would be much appreciated.
  #2 (permalink)  
Old July 10th, 2003, 10:19 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Cardiff, , United Kingdom.
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You could change the caption of the appropriate button when the tab is selected from "Update" to "&Update", and change all the other button caption's to "Update"

For example, if you have all 3 buttons in a control array cmdUpdate (cmdUpdate(0), cmdUpdate(1) etc.), you could do something like this:

Code:
cmbUpdate(0).Caption = "Update"
cmbUpdate(1).Caption = "Update"
cmbUpdate(2).Caption = "Update"

cmdUpdate(TabSelected).Caption = "&Update"
I hope that helps.

Regards
Owain Williams
  #3 (permalink)  
Old July 10th, 2003, 10:22 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Cardiff, , United Kingdom.
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You could always put that into a loop if you have more buttons:

Code:
For lngCount = cmdUpdate.LBound To cmdUpdate.UBound
   cmdUpdate(lngCount).Caption = "Update"
Next

cmdUpdate(TabSelected).Caption = "&Update"
There may be more efficient ways of doing this though.

Regards
Owain Williams
  #4 (permalink)  
Old July 10th, 2003, 04:07 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Alameda, ca, USA.
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Two cents.
In my opinion the Update button should be outside the tab, just like
the OK, Apply and Cancel buttons (in fact I will call it just Apply).
This is one of the GUI guidelines that I follow, but it is personal.

Marco


Quote:
quote:Originally posted by pgtips
 I have a problem with providing accelerator keys for buttons on a tab control.

Keeping it simple to save me typing, if I have a tab control with, say, 3 tabs and each tab has an Update button on it, how can I make it so that the user can hit <alt>U and that will fire the click event of the Update button on the tab that has focus. Needless to say each of the buttons has to have the caption [u]U</u>pdate.

Anyone got any neat tricks for this? Would be much appreciated.


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to disable a tab on a tab control. dbradley VB.NET 6 April 14th, 2011 10:04 AM
Tab Control prasanta2expert Access 4 November 27th, 2006 05:51 AM
Calendar Control with Tab Control Slicemahn Access 1 June 12th, 2006 10:35 PM
tab control p2pMember ASP.NET 1.0 and 1.1 Basics 1 March 9th, 2006 06:39 AM
Tab control Bhanu VS.NET 2002/2003 2 March 6th, 2005 04:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.