473,399 Members | 3,038 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,399 software developers and data experts.

DataBinding to Custom Class breaks after New instance: how to get around this?

Hi,

I'm having the following situation:

- A class clsFournisseur with public property's which raise a
MyPropertyChanged-event in the Set-method for each Property.
Public Event NomChanged As EventHandler
Public Property Nom() As String
Get
Return m_strNom
End Get
Set(ByVal Value As String)
m_strNom = Value
RaiseEvent NomChanged(Me, New EventArgs())
End Set
End Property
- A Form, with an instance of my clsFournisseur: "Private WithEvents
MyEntreprise As New clsFournisseur".
- Proprty's of this Myentreprise are bound to controls on the Form:
"Me.txtNom.DataBindings.Add("Text", MyEntreprise, "Nom")"

When I change the value in my txtNom.Text, the MyEntreprise.Nom-property is
changed. When I change the MyEntreprise.Nom, my txtNom.Text is changed.

So far so good. BUT:
When in my Form I want to use another clsFournisseur, there isn't anymore
databinding. I do this like this:
- MyEntreprise = New clsFournisseur(intEntrepriseID)
or
- MyEntreprise = New clsFournisseur()

I guess this is normal behaviour because, even when it still has the same
name, it isn't the same class anymore. But I still want to have this
databinding! And a weird thing: the txtNom.Databindings.Count = 1, so the
TextBox thinks there is still the databinding...

Does anybody know how I should do this? Am I doing anything wrong? Should I
Clear all the DataBindings after echt new instance of a class and put them
back?

Any help would be really appreciated.

Thanks a lot in advance,

Pieter
PS: I'm using the CTP from august of Visual Studio .NET 2005


Sep 20 '05 #1
3 1486
Pieter,

You are using forever for an "object" the name "class".

You bind to an object. If you have renewed that, than the binding is gone.

See it as this
dim a as object 'normally you use its type name by instance ThisClass
a = new ThisClass
a = new ThisClass

Now there are in fact two objects the first a and the second a. The first
one will be released by the GC as soon as that starts doing its job because
it has not any reference anymore.

I thought that this was the base of your question.

I hope this helps,

Cor
Sep 20 '05 #2
Thansk Cor, it's indeed the confirmation of what I thougt.
But isn't there any solution for the DataBinding? Is the only solution I
have to Clear all the DataBindings and than reset them back afterwarths?

Thansk anyways,

Pieter
"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:u3**************@TK2MSFTNGP12.phx.gbl...
Pieter,

You are using forever for an "object" the name "class".

You bind to an object. If you have renewed that, than the binding is gone.

See it as this
dim a as object 'normally you use its type name by instance ThisClass
a = new ThisClass
a = new ThisClass

Now there are in fact two objects the first a and the second a. The first
one will be released by the GC as soon as that starts doing its job because it has not any reference anymore.

I thought that this was the base of your question.

I hope this helps,

Cor

Sep 20 '05 #3
Pieter,

Your question is complete on MSDN

Databindings.clear

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

I hope this helps,

Cor
Sep 20 '05 #4

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

Similar topics

2
by: Colin Robinson | last post by:
Help please I have an example class called Person with 2 public properties Firstname and Lastname, I cant create a textbox on an asp.net form bound to the Person.Firstname property Can...
3
by: John Bailey | last post by:
When I first built a few web pages in ASP .Net 2.0, I thought it was great. The formview and detailview contorls would automatically layout the controls for you, the update methods were...
3
by: Steve Franks | last post by:
Is there a way I can extend the HttpContext or one of its subclasses to include a property that exposes a custom class of mine to all ASP.NET pages? More specifically, I'd like to use a...
3
by: DraguVaso | last post by:
Hi, I'm having the following situation: - A class clsFournisseur with public property's which raise a MyPropertyChanged-event in the Set-method for each Property. Public Event NomChanged As...
8
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
8
by: Joey Chömpff | last post by:
L.S., Hello is there a way to implement 2-way databinding without using the datasources from dotnet 2.0. Why would you ask? Now that's simple. I've created an object model with BusinessObjects...
19
by: Jamey Shuemaker | last post by:
I'm in the process of expanding my knowledge and use of Class Modules. I've perused MSDN and this and other sites, and I'm pretty comfortable with my understanding of Class Modules with the...
15
by: Jeff Mason | last post by:
Hi, I'm having a reflection brain fog here, perhaps someone can set me on the right track. I'd like to define a custom attribute to be used in a class hierarchy. What I want to do is to...
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...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.