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

Binding between objects

I'm desperate! :-/.

I'm desperately trying to bind to objects together to share same data and to display it in a windows forms.

I'm trying to bind an custom object to custom control property. I do have integer selectionid "targetid" in my control and I'm trying to bind the (int) selectionid "sourceid" from my custom data source.

How can it be done? I've tried the following with no luck:

control.DataBindings.Add( "targetId", myCustData, "sourceId" );

How can this be achieved? Please help. Thanks in advance.

Nov 16 '05 #1
1 1576
Antero,
I'm desperately trying to bind to objects together to share
same data and to display it in a windows forms.

I'm trying to bind an custom object to custom control
property. I do have integer selectionid "targetid" in
my control and I'm trying to bind the (int) selectionid
"sourceid" from my custom data source.
The following article covers binding objects to controls.

http://msdn.microsoft.com/library/de...et02252003.asp

Here is a (VB.NET) sample binding to multiple properties, with
notifications:

Public Class Person

Public Event Text1Changed As EventHandler
Public Event Text2Changed As EventHandler

Private m_text1 As String
Private m_text2 As String

Public Sub New()
m_text1 = String.Empty
m_text2 = String.Empty
End Sub

Public Property Text1() As String
Get
Return m_text1
End Get
Set(ByVal value As String)
m_text1 = value
OnText1Changed(EventArgs.Empty)
End Set
End Property

Public Property Text2() As String
Get
Return m_text2
End Get
Set(ByVal value As String)
m_text2 = value
OnText2Changed(EventArgs.Empty)
End Set
End Property

Protected Overridable Sub OnText1Changed(ByVal e As EventArgs)
RaiseEvent Text1Changed(Me, e)
End Sub

Protected Overridable Sub OnText2Changed(ByVal e As EventArgs)
RaiseEvent Text2Changed(Me, e)
End Sub

End Class
Public Class PersonForm
Inherits System.Windows.Forms.Form

' ... designer generated code

Private aPerson As New Person

Private Sub Person_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.TextBox1.DataBindings.Add("Text", aPerson, "Text1")
Me.TextBox2.DataBindings.Add("Text", aPerson, "Text2")
End Sub

End Class
Hope this helps
Jay
"Antero" <An****@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com... I'm desperate! :-/.

I'm desperately trying to bind to objects together to share same data and to display it in a windows forms.
I'm trying to bind an custom object to custom control property. I do have integer selectionid "targetid" in my control and I'm trying to bind the
(int) selectionid "sourceid" from my custom data source.
How can it be done? I've tried the following with no luck:

control.DataBindings.Add( "targetId", myCustData, "sourceId" );

How can this be achieved? Please help. Thanks in advance.

Nov 16 '05 #2

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

Similar topics

0
by: Paul Keating | last post by:
I want my Python COM object to do early binding. I have this working for methods that return floats and dates and variants, but not for methods that return COM objects. They are returning IDispatch...
1
by: Raed Sawalha | last post by:
the first thing I searched the internet is what is the XML Binding? also while I;m reading the eSCORTE4js for SCORM i noticed the following comment // these functions handle the conversion to/from...
7
by: PC Datasheet | last post by:
I have this: Dim Cbr As Object Dim Ctl As Object Set Cbr = Application.Commandbars("CourseCalendarMonth") Set Ctl = Application.Commandbars("CourseCalendarMonth").Controls("CalendarMonth") Is...
9
by: Zlatko Matić | last post by:
I was reading about late binding, but I'm not completely sure what is to be done in order to adjust code to late binding... For example, I'm not sure if this is correct: early binding: Dim ws...
1
by: matty.hall | last post by:
There's a lot of information out there about data-binding UI objects (i.e. derived from Control) to non-UI custom business objects. Is it possible to do the same without any UI being involved at...
0
by: Ian | last post by:
I have sub-classed the Page class in order to provide some base properties and methods that every page on my site will need access to. I would like to have these things show up in the Simple...
5
by: Plat | last post by:
Summary: I've got some *.ASPX pages that still use COM objects. I'd like to enable Option Strict, but I get "error BC30574: Option Strict On disallows late binding" errors. How can I bypass this...
4
by: Alan Silver | last post by:
Hello, I'm trying to use an ArrayList to do data binding, but am getting an error I don't understand. I posted this in another thread, but that was all confused with various other problems,...
10
by: Fares Eidi | last post by:
I am a VB6 intermediate programmer just starting out using VB.net and would like to ask what I'd be missing out on if I just use time saving techniques like data binding, data adapter wizards etc...
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: 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
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
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...
0
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...
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...

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.