|
-
Jun 7th, 2005, 06:55 AM
#1
Thread Starter
Lively Member
Component Name Property Problem[RESOLVED]
Hi Guys.
Can any of you advise me?
I you drop a custom component called say "Fred" onto a form it is automatically named "Fred1", drop another and it will be called "Fred2" etc. So far so good.
You then create a function that takes a "Fred" as an input parameter, for example:
public void DoSomethingWithFred(assemblyName.Fred myFred)
{
// Some Code
}
In this example, how do you get at the Name of myFred? (Fred1 or Fred2 etc.)
The Name parameter that is shown on the form designer does not seem accessible.
If I try myFred.ToString() I get something Like "assembly.Fred".
I'm sure this is a fairly simple matter and that I am just being a bit thick, but any help would be appreciated.
Last edited by StoneTheCrows; Jun 8th, 2005 at 06:01 PM.
Reason: All Done!
 StoneTheCrows
_______________
The future will be better tomorrow. (George W. Bush)
(If you think my post was useful, please Rate it. Thanks)
-
Jun 7th, 2005, 06:57 AM
#2
Re: Component Name Property Problem
Have you tried the ID property?
-
Jun 7th, 2005, 07:09 AM
#3
Thread Starter
Lively Member
Re: Component Name Property Problem
 Originally Posted by mendhak
Have you tried the ID property?
Hi mendhak,
I just tried, but couldn't access it.
The Fred Class is declared with
public partial class Fred : Component
{
// Stuff
}
When I Enter Fred. I don't see ID as part of the intellisense suggestions. How should I access it?
By the way, this is with VS2005 Beta2 if that makes any difference!
 StoneTheCrows
_______________
The future will be better tomorrow. (George W. Bush)
(If you think my post was useful, please Rate it. Thanks)
-
Jun 7th, 2005, 08:12 AM
#4
Thread Starter
Lively Member
Re: Component Name Property Problem
Maybe I need to use Reflection?
Any Ideas?
 StoneTheCrows
_______________
The future will be better tomorrow. (George W. Bush)
(If you think my post was useful, please Rate it. Thanks)
-
Jun 8th, 2005, 04:10 AM
#5
Re: Component Name Property Problem
When you drop it onto the form and access the property grid, is there a property that has the name stored in it?
Is Fred your own control, because you could then modify it and include an ID property.
-
Jun 8th, 2005, 06:01 PM
#6
Thread Starter
Lively Member
Re: Component Name Property Problem
 Originally Posted by mendhak
When you drop it onto the form and access the property grid, is there a property that has the name stored in it?
Is Fred your own control, because you could then modify it and include an ID property.
The Name property is the (Name) under the Design Category. This just doesn't seem available anywhere else.
Yes 'Fred' is my own Component. It's not a Control, if it was, I don't think there would have been an issue. Anyway I had already come to the same conclusion that you did and done as you suggested. It's a perfectly adequate solution, I just don't like to create additional properties when something already floating around will do the job.
Thanks for your help.
 StoneTheCrows
_______________
The future will be better tomorrow. (George W. Bush)
(If you think my post was useful, please Rate it. Thanks)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|