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.
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 ;)
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
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.
Re: set item property values dynamically?
Quote:
Originally Posted by
Shaggy Hiker
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.
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.
Re: set item property values dynamically?
thanks..
haven't had the chance to try this yet.
will get back to you.