473,398 Members | 2,212 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,398 software developers and data experts.

Advanced Databinding with Reflection

Databinding with reflection

I have a class, SmartString:

Public Class SmartString

...Psuedo code follows

Public Property Value() as String
Return Me.Text
End Property

Public Property IsNotNothing() as Boolean
Return m_IsNotNothing
End Property

End Class

Then, I have a Main Class:

Public Class MyClass

...Psuedo code follows

Public Property SPECIAL_TEXT() as SmartString
Get
Return m_SpecialText
End Get
Set(ByVal Value as SmartString)
m_SpecialText = Value
End Set
End Property
End Class

Then, on another form, I'm using reflection to dynamically create
labels and textboxes to display.

Dim obj as Object = Activator.CreateInstance(MyClass)
Dim pInfoArray() as PropertyInfo

For Each pInfo as PropertyInfo in pInfoArray

Dim NewTextBox as TextBox
NewTextBox.Name = pInfo.Name
NewTextBox.DataBindings.Add("Text", obj, pInfo.Name & ".Value")
NewTextBox.DataBindings.Add("Enabled", obj, pInfo.Name &
".IsNotNothing")
Me.Controls.Add(NewTextBox)

Next

The above code throws an error. What I'm trying to do is Bind the
TextBox's "Text" field to the Value field of the SmartDate Property
(SPECIAL_TEXT), and the TextBox's "Enabled" field to the IsNotNothing
field of the SmartDate Property (SPECIAL_TEXT).

If SPECIAL_TEXT was just of type "String", then I could add the
databinding simply by calling NewTextBox.DataBindings.Add("Text", obj,
pInfo.Name).

How can I bind when SPECIAL_TEXT is of the type SmartString?

Thanks for any help anyone can provide.

-Jason

Mar 17 '06 #1
0 1227

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

Similar topics

0
by: Wiktor Zychla | last post by:
Hello, I am thinking of a general solution to the specific issue and I hope someone has some more experience on that. Up to now I use the ListView as the primary control for collections of...
3
by: Kevin Swanson | last post by:
I'm writing what should be a very simple app against an Oracle database. The app has a number of user controls, any one of which is loaded into a main display page using the loadControl method,...
1
by: udupi_mail | last post by:
Can anybody suggest possible databinding options which would bind(map) xml instance docs(which conforms to some pre-defined xsd) to a PRE-EXISTING java object (see below example). I looked at...
8
by: Dirk | last post by:
Hello, I have a problem to use databinding with my business layer classes. My data class does not have simple properties (string, int or datetime), instead, all my properties are objects of the...
2
by: udupi_mail | last post by:
Hello, Was hoping to get some feeback on the following: Current arch. is a swing client with corba services deployed on AIX. Data tranferred over the wire is XML(string) instead of traditional...
1
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hello to all, I want to know if DataBinding in asp.net 2,0 is better than to fill up the values of the controls of the following form: this.miControlTextBox.Text = valorParaControlTextbox; ...
3
by: Mauro D. | last post by:
Hi, In my usercontrol I bind the BindingSource I pass via property to all the control inside the usercontrol. For example Control ctl=new TextBox(); ctl.DataBindings.Add("Text", binding,...
2
by: cjard | last post by:
I ask, because I have a textbox bound to a bindingsource, which is bound to a datatable(row) The datatable is typed, and hence exports a Property called Column1 I added another property to the...
2
by: Matt | last post by:
Hi, Is it possible to write a method which can take both a normal instansiated type and reflection instansiated type? For example, the following code doesn't work. It throws a casting...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
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...

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.