1 Attachment(s)
Validate Event (Take two)
Hi everybody !
I have already asked the same thing here:http://www.vbforums.com/showthread.php?t=436068
Now Im back, because I dont found the solution ???
I attached with this thread, a very little project that shows my problem...Cloud you try it please ?
I have a textbox (Text1) with a validate event. If this textbox is empty it's supposed to keep the focus and it's not the case because I can go to another TAB ? Why ? Is it normal or no ?
Thanks for your help !
Re: Validate Event (Take two)
This will fix it.
VB Code:
Private Sub Text1_LostFocus()
If LenB(Trim(Text1.Text)) = 0 Then
SSTab1.Tab = 0
Text1.SetFocus
End If
End Sub
Re: Validate Event (Take two)
Just to be sure, I can erase this Text1_Validate(Cancel As Boolean) ???
Re: Validate Event (Take two)
Quote:
Originally Posted by DubweiserTM
Just to be sure, I can erase this Text1_Validate(Cancel As Boolean) ???
I'm guessing at the functionality you want but no. My change only checks when you change to a different tab and not if you go to a different control on the same tab.
Re: Validate Event (Take two)
Using Lost_Focus cannot be a solution, though. That will defeat the purpose of validation.
it's quite interesting - running your project "as is" replicates the probles you described. However, replacing original tab control with new "fixes" the problem. And I couldn't find any discrepancies in the settings... Strange.
Re: Validate Event (Take two)
Re: Validate Event (Take two)
Quote:
Originally Posted by RhinoBull
Using Lost_Focus cannot be a solution, though. That will defeat the purpose of validation.
it's quite interesting - running your project "as is" replicates the probles you described. However, replacing original tab control with new "fixes" the problem. And I couldn't find any discrepancies in the settings... Strange.
Im not really sur if I understand you ? I delete the TAB and I add a new one ? If its this I tried it and it's not okay..
Re: Validate Event (Take two)
Quote:
Originally Posted by DubweiserTM
Im not really sur if I understand you ? I delete the TAB and I add a new one ? If its this I tried it and it's not okay..
Well, it is for me... :) So, it must be the control on your system. Did you install all service packs?
Or, perhaps you want to try using TabStrip control instead. It's not a container so you would have to use Picturebox or frame for each tab you create but it's better control over all and always prefer it to SSTab.
Re: Validate Event (Take two)
I'm sorry Rhino but I don't understand why you say that the "Lost_Focus cannot be a solution". I would expect that the Validate event would fire when the tab is changed but if it doesn't then what's the matter with checking the textbox value on the tab number change and if it fails validation then stetting focus to the textbox?
Re: Validate Event (Take two)
If Validate isn't fired (and it must) then there is something wrong with tab control itself because it doesn't fire validation. If I ddn't see it myself I wouldn't believe it... I haven't seen it before... And Lost_Focus is no substitution for the Validate (and visa versa)... Each event is important and has its purpose.
Re: Validate Event (Take two)
Quote:
Originally Posted by RhinoBull
If Validate isn't fired (and it must) then there is something wrong with tab control itself because it doesn't fire validation. If I ddn't see it myself I wouldn't believe it... I haven't seen it before... And Lost_Focus is no substitution for the Validate (and visa versa)... Each event is important and has its purpose.
All true but sometimes you need to be pragmatic.
Re: Validate Event (Take two)
Perhaps... but I like to find the clean way or cause of the problem if possible first ... if not then I'll worry about the work arround. :)
Re: Validate Event (Take two)
Do I have to call Bill Gates ??? :) :) :)
Re: Validate Event (Take two)
Interesting! The Label controls seem to be causing the problem. Remove them and everything works as expected.
The usual fix : use a Frame control on every Tab and put your controls in the Frame. Using Frames solves many quirks with the SSTab, including this one.
[Edit]
I just ran some more tests. It seems the problem occurs if there is at least one Label, Image, Line or Shape control anywhere on the SSTab (any Tab). I can't remember if I have VB SP6 installed on this pc. My versions are
VB - 6.0.81.76
MSVBVM60 - 6.0.96.90
TabCtl32 - 6.0.90.43
Re: Validate Event (Take two)
Quote:
Originally Posted by brucevde
Interesting! The Label controls seem to be causing the problem.
It's quite Interesting! I couldn't let go so I did the same thing - deleted both labels - and I can confirm that label control causes validate event not to fire when you switch between the tabs. But this is really insane - labels are not even windows (nor are the image, line or shape controls) !!!
Btw, frames don't help either - it must be something written within the tab control itself...
As I said earlier "If I din't see it myself I wouldn't believe it"... :ehh:
Just another argument against using SSTab.
Re: Validate Event (Take two)
Quote:
Btw, frames don't help either - it must be something written within the tab control itself...
Using frames solved this problem for me.
Re: Validate Event (Take two)
Quote:
Originally Posted by brucevde
Using frames solved this problem for me.
ditto, and is indeed one of the suggested work-arounds
Re: Validate Event (Take two)
Strange... It didn't for me and I tried all kind of groupping on a single frame and/or multiple... no luck... It's no bother to me as I never use SSTab control (nor any control from infamous Sheridan controls library) but it's interesting enough because non-windowed control causes validation issues.
Re: Validate Event (Take two)
Quote:
Originally Posted by bushmobile
No, it isn't for me so it is not the solution.
Solution (in my opinion) is to avoid using that control completely. It is convenient (because it's a container) but very buggy.
Re: Validate Event (Take two)
Quote:
Originally Posted by RhinoBull
....Solution (in my opinion) is to avoid using that control completely....
I will remember all the $%@%# trouble I had with this control, for now it's too late to replace it with TabStrip...