Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SStab click event and tab activate

Status
Not open for further replies.

bsanthu

Programmer
Oct 31, 2002
14
IN
Hi all,
I am using SStab control from the Microsfot tabbed controls. In my tab i
have 3 tabs. I have some controls in first tab. When I click tab 3 , some
validation has to happen with controls in the first tab. That is happening
when i click 3rd tab. But before the validation is over with success , the
3rd tab content should not be visible. If the validation fails the active
tab should not happen for the clicked tab. But what happening is when i
click 3rd tab, the 3rd tabs become active tab, then the click event of tab
is happening which is containing the validation code.

Is it possible to change this behaviour.

Thanks in advance for any help.....


-Regards
Santhakumar B

 
The SSTab control has a MouseDown event which fires before the Click event. It doesn't directly tell you which tab the mouse was clicked on, but you can figure it out. You can do your validation at that point. I believe that you can also avoid setting the focus to the 3rd tab if the validation fails by setting the focus to the tab with the error.

Another approach that you might want to consider is starting off with the controls on the 3rd tab either disabled or hidden and only enabled (and visible) when the data on the other tabs has been validated. You can change the visible and enabled properties of controls which are not on the currently selected tab.
 
An easy way to do what BlackburnKL is suggesting is to place all of the controls on tab 3 on a frame. Then when you want to hide or show these controls, just change the frames visible property value. All controls that are contained on a frame are only visible if the frame itself is visible. Also, as you add controls to the tab (frame), you don't have to change your code to add the new controls name. You can also set the frame to no border or caption, and make it's background color match the forms. This prevents the frame from being seen by the user even when it is visible (frame is there and visible, it just "blends in")

 
Mr BlackburnKL ,
Thanks for your tip. The click event is fired only at the tab leaves(top). But the mouse down event is fired all over the tab area. I dont want to call my validation if mouse down event is fired on tab areas. Is their a way to find whether the mouse down is fired on tab headers or in tab area?.

-Regards
Santhakumar B
 
bsanthu,

The SSTab control has a .Tab property that tells you which tab is active. The .MouseDown event has X and Y coordinates associated with it which may allow you to mathematically determine which tab you clicked on.

If your tab control's .Style property = ssStyleTabbedDialog and the .TabOrientation property = ssTabOrientationTop and the .TabsPerRow property = the .Tabs property, then the tabs are equally spaced in one row across the top. If these three properties are not set that way, the calculation gets ugly.

If these three properties are set as indicated, you can use the following formulas to determine what you need to know.

Formula to determine if just the top tab area was clicked:

lngResult=Y-SSTab1.Top-SSTab1.TabHeight

If the result is negative, then the mouse was clicked on one of the actual tabs themselves.

Formula to determine which tab was clicked:

lngTab=Int((X-SSTab1.Left)/(SSTabl1.Width/SSTab1.Tabs))

You could use this to change the active tab using the following command:

SSTab1.Tab = lngTab

Of course, you will need to replace "SSTab1" with the name of your SSTab control. Other than that, this should work for you.

Good luck,

BlackburnKL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top