473,382 Members | 1,752 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,382 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


Nov 21 '05 #1
3 978
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
Nov 21 '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

Nov 21 '05 #3
Pieter,

Your question is complete on MSDN

Databindings.clear

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

I hope this helps,

Cor
Nov 21 '05 #4

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

Similar topics

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...
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...
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...
1
by: Mark Olbert | last post by:
Has anyone else noticed that the design-time support for databinding in custom controls in ASPNET2 sucks? At least for GridViews? So far I've spent going on two days trying to get the following...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
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...

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.