Link to home
Start Free TrialLog in
Avatar of BALAJI
BALAJI

asked on

how can i get the .Name property of a referenced control?

If I put a control on a form and then programaticly create another control of the same type then set that 2nd control = to the one on the form I create a reference to the orginal control. But I can not seem to get the .Name property of the orginal control I set the reference to.

Although that doesn't sound like it makes sense because I would have had the name of the control to set the programaticly created one to eqaul it, it is not that simple.

My programaticly created one was set to it through the use of a collection object so I dont actually know the name of the control it was set to. For some reason the .Name property does not show up when I see the list of properties/methods after the "." when typeing its name..


I might add that the control is a custom created user control. When I type the controls name explicitly I see the name property in the list but when I type the  referenced objects name i dont see the .name property in the list.


Case where I see the .Name Property:

   form_Customer.GDBE_Customer.Name

Case when I DONT see the .Name Property:

   dim TempObject as GDBE
   set TempObject = form_Customer.GDBE_Customer

Then If I typed:

   TempObject.(Here I would see all my public methods/properties, but Name does not show up!)

any Ideas?



Avatar of Elmo_
Elmo_
Flag of Ireland image

BALAJI,

Are you trying to set a temp object equal to that control??  
What type of control are you using on Form_Customer??
What are you actually trying to do??

Elmo
Avatar of AZWolf7
AZWolf7

Is GDBE_Customer explicitly declared as a GDBE control? Can you show us the declarations of the collection and how it is being set?
Avatar of BALAJI

ASKER

yes GDBE_Customer and TempObject are being explicitly declared as a GDBE control. the collection is the SelectedControls collection of the PropertyPages, but that is besides the point because as you can see in my example above which uses no collections it still does not work.
i imagine it must be some sort of functionality left out of the user control.  i am not sure what all it entails to code that into a user control, but seeing that regular controls do not suffer from this problem, i would imagine it has something to do with the said control.
TempObject.Object.Name
ameba,
if the .name property is seen under normal conditions when the control is referenced directly, why would the property now all of a sudden be found under its .object property?
It won't be found - no property will show when you type 'object.', but it will be possible to use the property (I hope :)
When some property of the user control does not work, adding .Object. usually helps.
That has to do with getting property or method *to work*.

To *see* a property 'Name' of your control, well, you won't see it when you type 'dot' if user control is in your project. You will see only properties *you* provided. The 'Name' property is provided by Unknown4._UserControl library.

When user control is NOT in your project (e.g. it is in separate OCX project), Intellisense will show 'full' set of properties.
Avatar of BALAJI

ASKER

the .Object.Name does not work either. Is there any other way to return the name property?

I did not add the name property to my user control because it automaticly appeared when I dropped it on a form, do i need to add it for it to work?

And if i need to add it how should I go about doing that?

The only other Thing I can think of is to make a user defined property called Name2 or something like that and make sure that equals the .Name property.. but that is not really the best way so do you have any more ideas?
What about using separate OCX project for your usercontrol?
Avatar of BALAJI

ASKER

I figured it out myself, I need to make a custom property that assigns the the value of UserControl.Extender.Name to the property then I can read that user created property from my property page.
Avatar of BALAJI

ASKER

This question has a deletion request Pending
This question no longer is pending deletion
>I figured it out myself, I need to make a custom property ...

Did you figure it yourself? My comment:

"You will see only properties *you* provided."

didn't help you?
Avatar of BALAJI

ASKER


I didn't care if i could see the .Name property only If i could get the value of the .Name property, I could care less if it shows up in the list, but your suggestion was to use the .Object.Name property which didn't work at all. So the only way i could get this to work the way I needed was to create a user property called ControlName:

Public Property ControlName() as string
    ControlName = usercontrol.name
End Property


And nothing you said mentioned at all that this is how I could get it. You just said I would only see my own properties, and methods in the list, but my question was how can I return the .Name property of a user control.

----Ameba's comment----
>I figured it out myself, I need to
Did you figure it yourself? My comment:

"You will see only properties *you* provided."

didn't help you?

Avatar of BALAJI

ASKER

This question has a deletion request Pending
This question no longer is pending deletion
>your suggestion was to use the .Object.Name property which didn't work at all

No, it didn't. But this is not the only suggestion I made. I was reffering to my other comment.
Avatar of BALAJI

ASKER

Ameba,

What comment were you reffering to?
ASKER CERTIFIED SOLUTION
Avatar of ameba
ameba
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BALAJI

ASKER

All along I knew I could see only the proeprties I created that is why I was askig the question on how to see(have access) the intrinsic ones. Your comment didn't tell me anything I had not known comming into this question. I was looking for a way around creating a custom property for the name.
Avatar of BALAJI

ASKER

I think you ment to post the below in this question but you posted in another question. I will accept this as an answer to this question. Thank you for the detail.

If you have ALL, UserControl and Project with 5 forms in one, *single* vb project, you cannot work properly/easy, because vb ide is not user friendly for this, as I commented in your other question:

"To *see* a property 'Name' of your control, well, you won't see it when you type 'dot' if user control is in your project. You will see only properties *you* provided. The 'Name' property is provided by Unknown4._UserControl library.

When user control is NOT in your project (e.g. it is in separate OCX project), Intellisense will show 'full' set of properties."
Avatar of BALAJI

ASKER

Comment accepted as answer
>I think you ment to post the below in this question

No, it goes with my description of two roles "OCX author" and "Developer". I noticed here that you keep them together - two projects in one vbp.
Avatar of BALAJI

ASKER

i do that so I can debug my control. At a later time I will compile it and seperate it from my progject