473,387 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

set complex property on the fly

Hi folks,

I have a Treeview control in the Winform, and I want to change the text of
the 5th node base on an expression:

dim sObject as string = "Treeview1.Node.Items(5).Text"

dim sValue as string = "New Text for the node"

How can I make this happen by using reflection or any other way?

Basically, my question is how I can make change to a complex property:

Object.Property.property

Thanks for any ideas.

George
Dec 3 '05 #1
3 1041

You'll need to:
(1) parse your expression string, then use the System.Reflection API to get
the values of each sub-property in turn.
or
(2) Comple the expression and load the resulting assembly (requires compiler
installed)
or
(3) Choose a scripting language that can handle your expression, and ask it
to evaluate your expression. (Try IronPython- that should work for you.)

m
"George Meng" <ge************@sohu.com> wrote in message
news:e5****************@TK2MSFTNGP15.phx.gbl...
Hi folks,

I have a Treeview control in the Winform, and I want to change the text of
the 5th node base on an expression:

dim sObject as string = "Treeview1.Node.Items(5).Text"

dim sValue as string = "New Text for the node"

How can I make this happen by using reflection or any other way?

Basically, my question is how I can make change to a complex property:

Object.Property.property

Thanks for any ideas.

George

Dec 4 '05 #2

"Mike" <vi********@yahoo.com> wrote in message
news:ez****************@TK2MSFTNGP11.phx.gbl...

You'll need to:
(1) parse your expression string, then use the System.Reflection API to
get the values of each sub-property in turn.
or
(2) Comple the expression and load the resulting assembly (requires
compiler installed)
or
(2a) Parse your expression string, and use Reflection.Emit to generate code
on the fly, and load the assembly. (I didn't mention this before, as it's
the hardest and probably won't by you much over (1) unless you call the same
expression over and over many times
or
(3) Choose a scripting language that can handle your expression, and ask
it to evaluate your expression. (Try IronPython- that should work for
you.)

m
"George Meng" <ge************@sohu.com> wrote in message
news:e5****************@TK2MSFTNGP15.phx.gbl...
Hi folks,

I have a Treeview control in the Winform, and I want to change the text
of the 5th node base on an expression:

dim sObject as string = "Treeview1.Node.Items(5).Text"

dim sValue as string = "New Text for the node"

How can I make this happen by using reflection or any other way?

Basically, my question is how I can make change to a complex property:

Object.Property.property

Thanks for any ideas.

George


Dec 4 '05 #3
Thanks Mike, your suggestions are very helpful. I prefer to use reflection
to do it.
I will try.

"Mike" <vi********@yahoo.com> дÈëÏûÏ¢ÐÂÎÅ:ux***************@TK2MSFTNGP12.phx.gb l...

"Mike" <vi********@yahoo.com> wrote in message
news:ez****************@TK2MSFTNGP11.phx.gbl...

You'll need to:
(1) parse your expression string, then use the System.Reflection API to
get the values of each sub-property in turn.
or
(2) Comple the expression and load the resulting assembly (requires
compiler installed)


or
(2a) Parse your expression string, and use Reflection.Emit to generate
code on the fly, and load the assembly. (I didn't mention this before, as
it's the hardest and probably won't by you much over (1) unless you call
the same expression over and over many times
or
(3) Choose a scripting language that can handle your expression, and ask
it to evaluate your expression. (Try IronPython- that should work for
you.)

m
"George Meng" <ge************@sohu.com> wrote in message
news:e5****************@TK2MSFTNGP15.phx.gbl...
Hi folks,

I have a Treeview control in the Winform, and I want to change the text
of the 5th node base on an expression:

dim sObject as string = "Treeview1.Node.Items(5).Text"

dim sValue as string = "New Text for the node"

How can I make this happen by using reflection or any other way?

Basically, my question is how I can make change to a complex property:

Object.Property.property

Thanks for any ideas.

George



Dec 4 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: HQM | last post by:
If I create an element X of a primitive type with minOccurs=0 and nillable=true and run it through the WSDL generator I get a class with a property "X" of the primitive type plus a boolean...
4
by: Robert W. | last post by:
I'm thinking of building a complex data model with a number of nested classes but need to know something first. To simplify my question, let me present you this sample data model MainClass...
2
by: Lance | last post by:
I want to be able to reset a complex property in a PropertyGrid. I know that for properties that are ValueTypes you can include System.ComponentModel.DefaultValue in the declaration of the property....
1
by: Andrew | last post by:
How can I create a property or function for a typed datasets column? By this I need to add a new column (element) to the table or override an existing column. For instance I have an Invoice table...
1
by: Chris Dunaway | last post by:
Consider the following simple class: <Serializable()> _ Public Class SimpleClass Private m_AString As String Private m_AByteArray As Byte() Public Property AString() As String . . . End...
0
by: George Meng | last post by:
Hi folks, I have a Treeview control in the Winform, and I want to change the text of the 5th node base on an expression: dim sObject as string = "Treeview1.Node.Items(5).Text"
2
by: Random | last post by:
I have a very full and complex object that contains objects as properties and a few collections, and I'm working to databind it to a page. A lot of textbox and dropdowns on the page, a few grids. ...
1
by: Craig Buchanan | last post by:
I have an class, named MessageTemplate, that has three properties: Name, Description, and Tokens. The Name and Description properties are strings. The Tokens property, however, is a...
1
by: daokfella | last post by:
I have a custom server control that exposes a property which is a complex type. I expose the property as such: public class Automobile { public AutomobileEngine Engine { get { object o =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.