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

Binding a Text Box

Help,

I give up... I have a class that I created.

In the Load call of a custom control I bind a text box to the class that I
created.
The code for that part is: TxtLast.DataBindings.Add(New Binding("Text",
CurrentRecord, "LastName"))

If I change the value of the class in the Load call the text box that it
bound to updates with the new value. So if within the Load Proc of the
control there is a line that says CurrentRecord.Lastname = "Smith" the text
box will display "Smith".

But, if I change the value in any other procedure within that control the
textbox does not update it's value. What am I doing wrong?

Thanks,
David
Sep 22 '06 #1
1 1176
Hi,

"David Miller" <dm*********@earthlink.netwrote in message
news:T2*****************@fe07.news.easynews.com...
Help,

I give up... I have a class that I created.

In the Load call of a custom control I bind a text box to the class that I
created.
The code for that part is: TxtLast.DataBindings.Add(New Binding("Text",
CurrentRecord, "LastName"))

If I change the value of the class in the Load call the text box that it
bound to updates with the new value. So if within the Load Proc of the
control there is a line that says CurrentRecord.Lastname = "Smith" the
text box will display "Smith".

But, if I change the value in any other procedure within that control the
textbox does not update it's value. What am I doing wrong?
If you are using NET1.1 then add an event (typeof EventHandler) for each
property and name it "propertyname"+Changed, eg:

Public Class Class1
Private _LastName As String

Public Event LastNameChanged As EventHandler
Public Property LastName() As String
Get
Return _LastName
End Get
Set(ByVal value As String)
If (value <_LastName) Then
_LastName = value
RaiseEvent LastNameChanged(Me, EventArgs.Empty)
End If
End Set
End Property

End Class

This should work in NET2.0 too, but in NET2.0 i would implement the new
INotifiyPropertyChanged instead on your class.

HTH,
Greetings

>
Thanks,
David

Sep 23 '06 #2

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

Similar topics

0
by: Wesman | last post by:
Why does the following code not work (displays the correct values in the second textbox). if i chane the OnFocusChange method to the following it will work: private void OnFocusChange(object...
19
by: Simon Verona | last post by:
I'm not sure if I'm going down the correct route... I have a class which exposes a number of properties of an object (in this case the object represents a customer). Can I then use this...
1
by: Bruce | last post by:
Hi, there, I meet a problem about comboBox binding. -------------------- Database: Northwind Tables: 1) Products 2) Categories I create a form (named "form1") to edit the record from...
3
by: Max | last post by:
Hello, I made a windows form with a combo box and 4 text boxes. All 5 objects should get their data from a data set which is populated in the form load method. The combo box has item ids. When...
7
by: Steve K | last post by:
First problem: I am specifying a format string for a Binding object like so: <code> Binding binding = new Binding("Text", item.EOBRemittance, "AmountAllowed", true, DataSourceUpdateMode.Never,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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:
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...

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.