Addressing Control Properties at runtime
Addressing Control Properties at runtime
Addressing Control Properties at runtime
Addressing Control Properties at runtime
Addressing Control Properties at runtime
Addressing Control Properties at runtime Addressing Control Properties at runtime Addressing Control Properties at runtime Addressing Control Properties at runtime Addressing Control Properties at runtime Addressing Control Properties at runtime Addressing Control Properties at runtime Addressing Control Properties at runtime
Addressing Control Properties at runtime Addressing Control Properties at runtime
Addressing Control Properties at runtime
Go Back  Xtreme Visual Basic Talk > > > Addressing Control Properties at runtime


Reply
 
Thread Tools Display Modes
  #1  
Old 01-03-2014, 04:41 AM
randtek's Avatar
randtek randtek is offline
Contributor
 
Join Date: Jun 2002
Location: the Milky Way Galaxy
Posts: 532
Question Addressing Control Properties at runtime


Is it possible in VB.net to programmatically address properties of a control? I am having trouble even knowing how to ask this, but this is what I need to do:

Dim PropertyName as string = "Visible"

SomeControl.<PropertyName> = True ---->> Sets the *Visible* property of SomeControl to true
__________________
Murphy was an optimist!
Reply With Quote
  #2  
Old 01-03-2014, 05:35 AM
PlausiblyDamp's Avatar
PlausiblyDampAddressing Control Properties at runtime PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

There are ways to do this using reflection but these are quite horrible to code and debug, before going any further with that route is there a reason why you need to do this?

Will this be for any control at all or just a selected set of controls? Are these builtin controls or your own controls?
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #3  
Old 01-03-2014, 08:22 AM
Icehawke Icehawke is offline
Newcomer
 
Join Date: Aug 2013
Location: Elgin IL
Posts: 17
Default

You can do this... For example:

Code:
If chkbox1.checked Then textbox1.visible = True
Reply With Quote
  #4  
Old 01-03-2014, 10:22 AM
randtek's Avatar
randtek randtek is offline
Contributor
 
Join Date: Jun 2002
Location: the Milky Way Galaxy
Posts: 532
Default

I want to create a pair of functions that will save and load numerous parameters for a program. It would be nice to be able to just call something like this:

SaveParams(MyControl, PropertyToStore) -> Would be able to save value of selected property to a setup file, saving name of control, name of property, value of property to save.

LoadParams(MyControl, PropertyToLoad) -> Would load the previously saved parameters.
__________________
Murphy was an optimist!
Reply With Quote
  #5  
Old 01-03-2014, 03:20 PM
Gruff's Avatar
GruffAddressing Control Properties at runtime Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
Default

How many controls are we talking for your form? 10, 20, ... more?
What kind of properties? Can you be specific?
__________________
Burn the land and boil the sea
You can't take the sky from me


~T
Reply With Quote
  #6  
Old 01-03-2014, 05:16 PM
randtek's Avatar
randtek randtek is offline
Contributor
 
Join Date: Jun 2002
Location: the Milky Way Galaxy
Posts: 532
Default

Thanks for the responses. It looks like I will just have to code it using a myriad of conditional statements. I can do it that way, I just thought it might be simpler and more interesting to try to figure that alternative strategy out. I find those kind of problems to be fascinating.
__________________
Murphy was an optimist!
Reply With Quote
  #7  
Old 01-07-2014, 12:38 PM
PlausiblyDamp's Avatar
PlausiblyDampAddressing Control Properties at runtime PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

I had a bit of free time and looked into this (same reason, some problems interest me) and came across a VB function I have never used before CallByName (http://msdn.microsoft.com/en-us/libr...=vs.80%29.aspx)

It looks like that will do exactly what you are after without the need for reflection.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Addressing Control Properties at runtime
Addressing Control Properties at runtime
Addressing Control Properties at runtime Addressing Control Properties at runtime
Addressing Control Properties at runtime
Addressing Control Properties at runtime
Addressing Control Properties at runtime Addressing Control Properties at runtime Addressing Control Properties at runtime Addressing Control Properties at runtime Addressing Control Properties at runtime Addressing Control Properties at runtime Addressing Control Properties at runtime
Addressing Control Properties at runtime
Addressing Control Properties at runtime
 
Addressing Control Properties at runtime
Addressing Control Properties at runtime
 
-->