Binding a Text Box

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David Miller

    #1

    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.DataBin dings.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.L astname = "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


  • Bart Mermuys

    #2
    Re: Binding a Text Box

    Hi,

    "David Miller" <dmiller1023@ea rthlink.netwrot e in message
    news:T2YQg.9958 $fb3.9955@fe07. news.easynews.c om...
    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.DataBin dings.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.L astname = "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
    INotifiyPropert yChanged instead on your class.

    HTH,
    Greetings

    >
    Thanks,
    David
    >

    Comment

    Working...