Results 1 to 6 of 6

Thread: Component Name Property Problem[RESOLVED]

  1. #1

    Thread Starter
    Lively Member StoneTheCrows's Avatar
    Join Date
    Dec 2004
    Location
    UK
    Posts
    71

    Resolved 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)

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Component Name Property Problem

    Have you tried the ID property?

  3. #3

    Thread Starter
    Lively Member StoneTheCrows's Avatar
    Join Date
    Dec 2004
    Location
    UK
    Posts
    71

    Re: Component Name Property Problem

    Quote 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)

  4. #4

    Thread Starter
    Lively Member StoneTheCrows's Avatar
    Join Date
    Dec 2004
    Location
    UK
    Posts
    71

    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)

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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.

  6. #6

    Thread Starter
    Lively Member StoneTheCrows's Avatar
    Join Date
    Dec 2004
    Location
    UK
    Posts
    71

    Re: Component Name Property Problem

    Quote 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
  •  



Click Here to Expand Forum to Full Width