User Control Properties

Is there any way to access the user control properties within its own runtime(which could be at higher level design time)
i want to set a property and when i set it i want the user contol to then set its internal Ivisible at run time property and also in the resize event for the user control i want to set the height & width properties back to their default...ive tried everything
dim blah as usercontrol
set blah = myusercontrol
blah.width = 100

that doesnt work and when i do a me.width it doesnt show in the list ..the only thing that shows are  the controls public methods and custom properties ..not the standard ones !! arrgh this is so frustrating
can anyone help?
LVL 13
crazymanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

crazymanAuthor Commented:
Hmmm i have a feeling that this can't be done
0
HATCHETCommented:
crazyman,

Is this a custom ActiveX control that you've created?  If so, make the properties and methods you need Public, not Private.  If its NOT your ActiveX control, but a third party control... I don't think it can be done.  I could be wrong though.

HATCHET
0
AnswerTheManCommented:
look at this MSDN article :

"Understanding Control Lifetime and Key Events"

all the answers are in there.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

EyalCommented:
use usercontrol.someproperty for the usercontrol inner properties and for calling your personal properties just use the PropertyName
0
crazymanAuthor Commented:
umm within the user control when i type usercontrolname.height = blah i get method or data member not found ..the only properties it lets me set are the ones that i created that i made public ...how do i edit the ones in the property bag at run time?
0
EyalCommented:
use usercontrol.height, usercontrol.width for the usercontrol properties.

let say you have a property named "MyCaption"...
you can change this property by accessing to the right variable holding this property value or(less recommanded) you can do me.MyCaption = "some caption".
0
crazymanAuthor Commented:
yes that works outside of the compiled OCX but it doesn't wotk within the user control when i do me. the only properties available are my custom ones none of the property bag ones?!
0
crazymanAuthor Commented:
Someone try it and tell me if they get it ...create a new project ..activeX control then in the readproperties see if you can call the own user controls height property with me.height or usercontrol.height basically i can't do this...i have been told that it cant be done
0
crazymanAuthor Commented:
Adjusted points to 80
0
EyalCommented:
Option Explicit

Const lgcvar = ""

Private lgvar As String

Public Property Get var() As String
    var = lgvar
End Property

Public Property Let var(ByVal New_var As String)
    lgvar = New_var
    PropertyChanged "var"
End Property

Private Sub UserControl_InitProperties()
    lgvar = lgcvar
End Sub

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    lgvar = PropBag.ReadProperty("var", lgcvar)
End Sub

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    Call PropBag.WriteProperty("var", lgvar, lgcvar)
End Sub

' you can change lgvar anywhere in your usercontrol cade
0
crazymanAuthor Commented:
this still only allows me to change my own properties ..i have no problem with this but how do i change height ..width within the usercontrols code...
*sob*
0
crazymanAuthor Commented:
what if i declare a propery let and get for height ....would that work?
0
EyalCommented:
give me some problematic code
0
crazymanAuthor Commented:
Private Sub UserControl_InitProperties()
    Server = True
    Seperator = "|"
End Sub
Public Property Get Server() As Boolean
    Server = mblnServer
End Property

Public Property Let Server(ByVal Servers As Boolean)
    mblnServer = Servers
End Property

Public Property Let Seperator(strSeperator As String)
    prpstrGlobalSeperator = strSeperator
End Property
Public Property Get Seperator() As String
    Seperator = prpstrGlobalSeperator
End Property

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
On Error GoTo initerror
    Server = PropBag.ReadProperty("Server", False)
    Seperator = PropBag.ReadProperty(" Seperator", "|")
    Me.Height = IIf(Server, 2000, 0) <----this is causing the problem 'data member not found
    Me.InvisibleAtRuntime= IIf(Server, true,false) <----this is causing the problem same error
    GLOBAL_SEPERATOR = Seperator
    If mblnServer = True Then
        Winsock1.Bind 2222
        Winsock1.RemotePort = 3333
        Winsock1.RemoteHost = 'removed
    Else
        Winsock1.Bind 3333
        End If
Exit Sub
initerror:
    debug.print err.description & "  " & err.number
    MsgBox "Couldnt initialize the winsock please check the ports in use and try again", vbOKOnly, "Fatal Initialization Error"
End Sub

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    PropBag.WriteProperty "Server", Server, False
    PropBag.WriteProperty "Seperator", Seperator, "|"
End Sub

i changed the Iif's around that makes no differance i justcant set to those properties or any other then the ones i have defined myself
0
EyalCommented:
in the ReadProperties the control isn't visible yes so that is your problem.

try to change the usercontrol.height on the resize event of the usercontrol.
0
crazymanAuthor Commented:
I still get the same error :o(
data member or method not found
0
EyalCommented:
1)
InvisibleAtRuntime is readonly in runtime.

2)
remark the line :
Me.Height = IIf(Server, 2000, 0)

and put this following code:

Private Sub UserControl_Resize()
    UserControl.Height = IIf(mblnServer, 2000, 0)
End Sub

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
crazymanAuthor Commented:
Strange as VB refers to the usercontrol as usercontrol regardless of its name ...that seems a bit silly to me but oh well your right you get the points thanks for ur help
0
crazymanAuthor Commented:
Cheers
0
EyalCommented:
Now I hope you will have a nice day ;-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.