473,657 Members | 2,397 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

casting a string value for SetValue in PropertyInfo

Bob
This works only when the property return type is string:

SomeObjectsProp ertyInfo.SetVal ue(SomeObject, SomeStringValue , Nothing)

Is there a good way to try to automatically cast the string value I'm trying to
pass into SetValue as the correct type?

Bob

Nov 20 '05 #1
0 1536

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

Similar topics

4
8354
by: Alicia | last post by:
Hi all, I have a problem with an Enum and Reflection. I am using an Xml and Reflection to create some controls, and to set their properties. All goes well until I encounter one property which is defined like this: public enum MyType { Alpha = 0, Beta = 1 }
0
3815
by: Oliver | last post by:
hi - I'm trying to set Properties dynamically (web forms). The problem is that I can't seem to set the property value based on a string - even though I know the Type of the Property. I seem to have to convert the string to the correct Type for the property before I set it's value (using SetValue) - this is where I'm having trouble.
2
2341
by: Steve | last post by:
I'm in a weird situation where I'm using ComboBox's in a DataGrid. When the ComboBox selection changes, I'm currently storing the SelectedValue object into the DataSource of the DataGrid cell. This is not what I want. I want to bind a string to the datagrid, then bind the string and value of a lookup table to the combo box. When the combobox lookup is changed, I wanted to store the value in a different, unbound property of the bound...
5
1461
by: Erol | last post by:
How do I get a type from a string? I'm retrieving a string value from my database so that I can set my property values dynamically. In the event "Form1_Load", you will see that I'm trying to set the button's anchor property to "System.Windows.Forms.AnchorStyles.Bottom" dynamically from a string (which I commented out). How can I get this code to work. I also started to use the variable "fi", but I don't know how to put it to good use....
1
3951
by: Paul | last post by:
This part is easy: Dim oControl As Control oControl = Me.Page.FindControl("TextBox1") Dim oPropertyInfo As PropertyInfo oPropertyInfo = oControl.GetType.GetProperty("Text") oPropertyInfo.SetValue(oControl, "Some New Text", Nothing)
6
2095
by: andrea | last post by:
I want to setup properties value to an object created by reference. I do the following. T t = Activator.CreateInstance<T>(); Type newItem = typeof(T); newItem.GetProperty("PropertyA").SetValue(t, "Hello", null); It works fine, but I see that there is a GetProperties method that returns all properties available for a certain
3
3103
by: Matt Weaver | last post by:
I'm trying to setup a sub that would assign the properties of a webcontrol based on data in a table. I've setup a routine which looks like this: Private Sub SetObjectProperty(ByRef obj As Object, _ ByValPropertyName As String, _ ByVal PropertyValue As String) Dim wType As System.Type = obj.GetType Dim wProp As Reflection.PropertyInfo = _ wType.GetProperty(PropertyName)
13
3036
by: DaTurk | last post by:
Hi, This is a question brought about by a solution I came up with to another question I had, which was "Dynamic object creation". So, I'm curious if you can dynamically cast an object. If you have two object which have a common base class, they can both be cast up to the base class, but if either of the child classes have unuque methods you will not be able to access them. Now I know about late binding and all that stuff, but I need...
9
16000
by: FourEyes | last post by:
I've read that Reflection is slow and shouldn't be used when performance is a concern. In my case, performance is definitely a concern, so I was thinking that I could collect the PropertyInfo objects that I need at initialization, and then just call PropertyInfo.SetValue() at runtime. Can anyone tell me 1) how expensive is the call to PropertyInfo.SetValue() ? and 2) what is a better alternative ? I already have a hand-made solution...
0
8315
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8734
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8508
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8608
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6172
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4164
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2733
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1627
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.