473,386 Members | 1,754 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,386 software developers and data experts.

Type Conversion Query

Hi,

I have 2 classes, say B & C which are both inherited from the same
class, A.
Class A has a property which is used to hold a reference to a
subclassed form.
Class A also has a method that dynamically loads classes in the
following way:-

object objC;
objC = objDLL.CreateInstance("classname",true,BindingFlag s etc etc..;

Basically, the above method is executed in class B to instantiate
class C. Note the type "object" for objC as it needs to be wholly
generic.

What I need to do is copy the property from class B to class C. I have
written a generic routine to do this by passing the source property in
as "object" so I can use it for copying any property. The routine then
narrows "object" down to the target property type using ChangeType.

The problem I have in this case is that the property is not a
System.Type so some form of TypeConverter is needed as ChangeType will
throw an exception.

For the "SetValue" method I pass in the following parameters:-

The new class instance (object oObject)
The target property (string strProperty)
The value of the target property (object oValue)

Using reflection is fine for referencing the class instance and the
target property. But before I can use the SetValue method I have to
narrow down oValue to the same Type as the target property which
unfortunately - in this case - is a subclassed form and not a simple
type.

I would be very interested to hear from anyone that has done this.
I've read about ComponentConverter, ITypeDescriptorContext and so on
but am struggling.

Cheers.

Glyn.
Nov 15 '05 #1
0 799

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

Similar topics

1
by: Amir | last post by:
Hi all, I have a table called PTRANS with few columns (see create script below). I have created a view on top that this table VwTransaction (See below) I can now run this query without a...
1
by: deko | last post by:
Okay, so I figured out how to pull Outlook Appointments into an Access Table (see below). But the data comes in the wrong Data Type - how do I convert it from Text to Long Integer? For...
4
by: T!LT3D | last post by:
Hi I'm trying to convert data automatically from a SqlDataReader into the correct type for its class property, it goes something like this but is reported syntactilly incorrect.... MyField =...
10
by: Arno R | last post by:
Hi all, I have a database that I need to use in different versions of Access. This is A97 in most places and A2k in a few other locations. (I develop in A97 and convert the db to A2k for these...
2
by: john in fl | last post by:
Hello Everyone, I have an Append Query that worked fine in Access97 but now fails to work in Access 2000. The error that occurs is that it puts null values in a field due to a "Type Conversion...
2
by: midlothian | last post by:
Hello Trying to update a memo field in an update query using the Replace function, and am getting a type conversion error. Here is my parameter: CStr(Replace(CStr(),"$",Chr$(13) & Chr$(10))) ...
2
by: Reedsp | last post by:
OS: MS XP Access version: 2003 SP2 I am trying to use an update query to replace quote marks with nothing. In essence, I'm removing quote marks. I get a error message when a field is empty or...
7
by: bruce.dodds | last post by:
Access seems to be handling a date string conversion inconsistently in an append query. The query converts a YYYYMM string into a date, using the following function: CDate(Right(,2) & "/1/" &...
2
by: durgapur | last post by:
hi, i am trying to round off the value of a text field and then append it to a decimal field, but it's giving type conversion failure, below is the query plz help :- IIf(Len(CDbl())<8 And...
4
by: jehugaleahsa | last post by:
Hello: Say I were to query the schema tables from a database management system. Say I got a DataType field that held the string 'VARCHAR2'. Now, I know that VARCHAR2 associates to System.String....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.