Hello everybody. I'm having a very hard time with an ocx. I need to make the tooltiptext of an inner control coincide with Usercontrol.Extender.ToolTipText but unfortunately I discovered that the Extender object is totally unreliable. Just try the attached project, open it, open first the form at design time, then launch it. You'll see that when you first open it in design mode, the tooltiptext is correctly visualized, then it becomes null string at run time, and from then on it stays null. Something similar happens to all extender properties, such as CausesValidation. If you try to retrieve them via extender, you get unreliable values. What can I do? I can only use the extender for my project. Thank you.
Thats because you dont have any Read & Write properties set...
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.
Actually I discovered that the problem is not limited to the Extender object. If you create an ocx and write in its code
Code:
Private Sub UserControl_Resize()
Dim a As Control
For Each a In UserControl.Parent.Controls
Debug.Print a.ToolTipText 'or a.CausesValidation etc.
Next
End Sub
and then you change the relevant extender property of the ocx, it doesn't print the value you entered but the default value. And this doesn't happen everytime, but depending on the IDE history. I am totally in despair, seems like the ocx's extender properties can't be referenced inside the ocx code. I really need help to understand why... Please, somebody?
It's not really a bug, you are making two incorrect assumptions.
1. That an extender is available. Not all applications provide extenders and when they do, not all extenders offer the same properties. There is a minimum set of properties that extenders must provide; not sure if ToolTipText is one of them.
Anyway, this doesn't apply to your situation because VB does provide extenders. If you are ever interested whether one is provided or not, the usercontrol has a function
Usercontrol.ParentControls.ParentControlsType=vbExtender
2. And this is where your problem lies. The Extender isn't provided until the usercontrol is sited. You are only guaranteed that usercontrol is sited (i.e., placed on the form or in this case in an extender) in three events: InitProperties, ReadProperties & Show. If you want to access the extender do it in one of those events.
a. InitProperties occurs only once, the 1st time a control is created
b. ReadProperties occurs every time a created control is first loaded
Last but not least, a creator of many usercontrols in my time, I have learned to avoid the Extender for reason #1 above. I may be mistaken, but I doubt you absolutely need to reference the Extender, rather there are other ways to get what you want. If we knew why you are trying to get that info, we might be able to point you to those other ways.
Thank you for your reply. But are you saying that the usercontrol isn't necessarily sited on the Click, AccessKeyPress, MouseMove, KeyDown and so on events? They all occur after the Show event, so the control should be sited...
Should be. Take what I wrote as it was intended, keying on the word guaranteed. Can you access Extender in Resize event? Sure, after the uc has been sited but not before; therefore, not guaranteed. That same statement applies for every single event in the usercontrol and all the subs/functions/properties you eventually add to the usercontrol.
Anyway, did this tidbit of knowledge help you resolve your problem?
Last edited by LaVolpe; May 30th, 2009 at 10:51 AM.
Insomnia is just a byproduct of, "It can't be done"
Sure it did. However I tried to reference the extender within the ReadProperties event and had the same problems as before. Seems like the UC is only sited after the first Show event.
The fact it did doesn't guarantee it always will. When the messagebox was in the Resize event, sometimes it did show the tooltiptext, but not always. The same probably applies to ReadProperties...