Results 1 to 7 of 7

Thread: set item property values dynamically?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    403

    set item property values dynamically?

    hi all,

    i'm trying to create a procedure that changes an items property value dynamically.

    something like...

    Code:
        Public Sub SetItemProperty(ByVal item_name As String, ByVal property_name As String, ByVal value As String)
            item_name.property_name = value
        End Sub
    
       'Call it by.
       SetItemProperty("Textbox1", "Text", "Hello World")
    but of course that's just a sample of what i want to accomplish..

    i'd appreciate any help.

    thanks.

    VB Version: Microsoft Visual Studio 2008 Professional Edition
    .NET Version: Microsoft .NET Framework Version 3.5
    OS: Windows XP SP3

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: set item property values dynamically?

    You'd have to use reflection to accomplish that, search this forum for "Reflection Set Property" or something similar.

    Edit: I feel generous today, so I searched for you
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    403

    Re: set item property values dynamically?

    hi,

    thanks for the link... very informative.

    but the approach might not be applicable to my situation.

    forgive me if i didn't mention this earlier but the situation i am in right now is that i am planning to create this procedure inside an interface... which is why i planned to pass the control/item as string type instead of control type.

    what work-arounds can i do for this?

    thanks

    VB Version: Microsoft Visual Studio 2008 Professional Edition
    .NET Version: Microsoft .NET Framework Version 3.5
    OS: Windows XP SP3

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: set item property values dynamically?

    I may be mistaken, but I'd suggest that you explain your ultimate objective more thoroughly, as I feel that you have backed yourself into a corner from which any solution, if one exists, will be very difficult to create or maintain.
    My usual boring signature: Nothing

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    403

    Re: set item property values dynamically?

    Quote Originally Posted by Shaggy Hiker View Post
    I may be mistaken, but I'd suggest that you explain your ultimate objective more thoroughly, as I feel that you have backed yourself into a corner from which any solution, if one exists, will be very difficult to create or maintain.
    hi,

    to explain further, i have here a plugin architecture.. i have an MdiForm as the executable file.. then i have a couple of dll that has child forms and are loaded at runtime. i have reach the point where these child forms will need to modify items in the MdiForm like for example, I have a toolstrip on the MdiForm and it has a few ToolStripButtons. not all these buttons are enabled in every child form. some are disabled. so in my child form, i'm trying to find a way to disable the ToolStripButtons that are not required.

    i've thought of using another Interface for this as well and create procedures for each item but this will lead to a lot of codes. which is why i thought maybe i can use the approach i mentioned above which is to just use a procedure that can change item properties in the MdiForm dynamically just by specifying the item / control name, what property and the value.

    i'm not sure if it's possible thought.

    thanks.

    VB Version: Microsoft Visual Studio 2008 Professional Edition
    .NET Version: Microsoft .NET Framework Version 3.5
    OS: Windows XP SP3

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: set item property values dynamically?

    Your plugin interface should define a property that the parent form can read to determine which tool buttons and menu items should be enabled. It should also define an event that provides a notification when this property value has changed. The parent form can then read that property value and set the state of its own menus and tool bars.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    403

    Re: set item property values dynamically?

    thanks..

    haven't had the chance to try this yet.

    will get back to you.

    VB Version: Microsoft Visual Studio 2008 Professional Edition
    .NET Version: Microsoft .NET Framework Version 3.5
    OS: Windows XP SP3

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