Databinding -- need a Smart person! 
Author Message
 Databinding -- need a Smart person!

Someone has to know how to fix this...

I created an object called Entity, which has a property
called Name.  I then created an instance of this class,
called oEntity.  I am trying to bind the .Name property to
a textbox control (called txtName) on a form.  I thought I
had it figured out, but it just aint quite workin.  I was
able to bind it with code in form_load as follows:

txtName.DataBindings.Add(New Binding("Text",
oEntity, "Name"))

This works fine.  If oEntity.Name contains a value, it
will appear in the control when the form is loaded.  If I
then edit the value in the control, oEntity.Name is
updated to reflect whatever the control contains.  So far,
so good.  The problem occurs when I then change the
oEntity.Name property via code.  When I do this, for
instance:

oEntity.Name = "Test"

I cannot get the control to recognize the changed
value.  After setting oEntity.Name = "Test", I interrogate
txtName.Text and it does not reflect the new value of
oEntity.Name.

What have I done wrong?

Thanks much for your help!

-jd



Tue, 26 Apr 2005 23:41:06 GMT  
 Databinding -- need a Smart person!
Try

Public Event NameChanged as EventHandler

Public Property Name as String
    Get
        Return m_Name
    End Get
    Set(Value as String)
        m_Name = Value
        Raiseevent NameChanged(Me, System.EventArgs.Empty)
    End Set
End Property


Quote:
> Someone has to know how to fix this...

> I created an object called Entity, which has a property
> called Name.  I then created an instance of this class,
> called oEntity.  I am trying to bind the .Name property to
> a textbox control (called txtName) on a form.  I thought I
> had it figured out, but it just aint quite workin.  I was
> able to bind it with code in form_load as follows:

> txtName.DataBindings.Add(New Binding("Text",
> oEntity, "Name"))

> This works fine.  If oEntity.Name contains a value, it
> will appear in the control when the form is loaded.  If I
> then edit the value in the control, oEntity.Name is
> updated to reflect whatever the control contains.  So far,
> so good.  The problem occurs when I then change the
> oEntity.Name property via code.  When I do this, for
> instance:

> oEntity.Name = "Test"

> I cannot get the control to recognize the changed
> value.  After setting oEntity.Name = "Test", I interrogate
> txtName.Text and it does not reflect the new value of
> oEntity.Name.

> What have I done wrong?

> Thanks much for your help!

> -jd



Wed, 27 Apr 2005 23:36:28 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Very smart person needed here

2. Need help from Smart Person...

3. Newbie needs smart persons help....

4. Smart Delete Files And Smart Delete Folders Routines?

5. VB person needed (paid)...

6. non SQL person needs SQL expression!

7. I am in need of person who is familiar with Visaul basic, Powerbuilder, and C++

8. Full Time VB Person needed in NYC

9. New person needs help!

10. Delete person method needed !

11. VB person needed (paid)...

12. Need help in DataBinding

 

 
Powered by phpBB® Forum Software