Hi guys
is it possible, once getting hold of a propertyInfo instance to know when
the value of the property changed?
that is without requiring the property to raise an event on change
obviously...
maybe something with the PropertyInfo.GetSetMethod()? monitoring when that
method is called somehow?
how does the dataBinding mechanism work? seems to do the job, but how?
thanx,
Picho 2 2043
No, there's no way to do it using PropertyInfo, for two reasons.
First (and most obvious) because there's no such mechanism in .NET.
Second (even if there were such a mechanism), a PropertyInfo instance
_doesn't remember_ which object instance it came from (if any). Here
proof: you can get a PropertyInfo without having an instance of the
object at all:
PropertyInfo pi = typeof(MyClass).GetProperty("PropertyName");
PropertyInfo is pure metadata: it contains no information about any
object instance, so it can't help you if something about the instance
changes.
As to your second question, bindings do their job by requiring that
every property they're monitoring have a "...Changed" event. So, if you
have a class with a "BalanceDue" property, if you define an event
called "BalanceDueChanged" then you can bind that property to some
screen control using a binding. No event, no successful binding. No
magic involved at all. :)
Well, Figures.
thanx, I guess I have to stick to the OnChange thing.
b.t.w: is there a naming convention to link the property name to the event
name for the DataBinding to work?
thanx
Picho
"Bruce Wood" <br*******@canada.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com... No, there's no way to do it using PropertyInfo, for two reasons.
First (and most obvious) because there's no such mechanism in .NET.
Second (even if there were such a mechanism), a PropertyInfo instance _doesn't remember_ which object instance it came from (if any). Here proof: you can get a PropertyInfo without having an instance of the object at all:
PropertyInfo pi = typeof(MyClass).GetProperty("PropertyName");
PropertyInfo is pure metadata: it contains no information about any object instance, so it can't help you if something about the instance changes.
As to your second question, bindings do their job by requiring that every property they're monitoring have a "...Changed" event. So, if you have a class with a "BalanceDue" property, if you define an event called "BalanceDueChanged" then you can bind that property to some screen control using a binding. No event, no successful binding. No magic involved at all. :) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Nigel Sampson |
last post by:
ey all,
I'm in the process of creating a method of
tracking whenever an objects properties are changed. Since
its not possible to alter
existing types I decided to used a proxy generated using...
|
by: Lars Nielsen |
last post by:
Hi everybody,
I've run into a problem when using the reflection assembly on COM objects
and been browsing around the net for some while. Apparently a few has asked
the same question though no...
|
by: Frank Rizzo |
last post by:
Ok, I've heard all about reflection.
How do I print out the results for all the properties on this object:
System.Reflection.Assembly.GetExecutingAssembly().GetName()
I don't want a list of...
|
by: Sunny |
last post by:
Hi,
I have an old problem which I couldn't solve so far. Now I have found a post
in that group that gave me an idea, but I can not fully understand it.
The problem is: I'm trying to use a...
|
by: Roger Webb |
last post by:
Hey,
I'm attempting to use reflection in order to get the types of properties
in a class. However, I seem to be having trouble determining exactly which
type I am getting. In the foreach of...
|
by: Marc |
last post by:
Given a class 'Invoice' with a property 'public IMyColl<IInvoiceLine>
InvoiceLines' where 'IMyColl<T> : IList<T>' i would like to detect by
reflection that 'InvoiceLines' is a...
|
by: Aaron Queenan |
last post by:
Given the classes:
class Class
{
public static implicit operator int(Class c)
{
return 0;
}
}
class Holder
|
by: Oskar Lundgren |
last post by:
I want to iterate over fields declared like this, using reflection
(and there are good reasons for that):
Protected WithEvents Foo1 As Bar
Protected WithEvents Foo2 As Bar
....
I use the...
|
by: Lucas Tam |
last post by:
Hi all,
I need to set a property on a subclass such as:
Report.ExportOptions.ExportFormatType = ExportFormatType.Excel
AND
Report.ExportOptions.FormatOptions = excelFormatOpts
|
by: satankidneypie |
last post by:
Hi,
I'm going to start this off with some code as it'll make it easier to
explain afterwards...
using System;
namespace ConsoleApplication1
{
/// <summary>
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
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,...
|
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$) {
}
...
|
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...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
| |