Results 1 to 3 of 3

Thread: VB 3.5 : databinding an object property and modifying another property in code

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    589

    VB 3.5 : databinding an object property and modifying another property in code

    Hi,

    I have this crazy situation:

    on a Windows Form, an object myObject is bound to myObjectDataBindingSource like this:

    myObjectDataBindingSource .DatSource = myObject

    on the form, i have a check box bound to the property: chkProp1 for example of the object: myObjectDataBindingSource

    In the code when the checkbox is clicked, I need to go in code and change another text property of the object txtProper2 for example like this:

    Private Sub chkProp1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkProp1.CheckedChanged

    myObject.txtProper2 = newValue

    End sub


    The problem is that the event chkProp1_CheckedChanged ends up runing multiple times.

    It seems like if I am not allowed to change a second property while a bound property is runing its change event or something like that

    Have you ever got some thing similar ? am I supposed to do anything before changing a second property of an object while the change-event of a first property is being executed ?

    Thanks
    Thanks a lot for your help.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: VB 3.5 : databinding an object property and modifying another property in code

    is the myObject something that is under your control? Seems to me that if you have a property whose value is dependant on the value of another property, that becomes a business rule, and should be handled by the class, not the UI.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    589

    Re: VB 3.5 : databinding an object property and modifying another property in code

    myObject is a business object instance of a class: myClass. This class is implemented (inherits from) CSLA framework. It s a framewok that facilitates business rule, validation, object is dirty, is new.....etc

    So there is already logic in the class itslef, but i need sometimes to do stuff in the UI code as well, depending on other UI controls.
    Thank you
    Thanks a lot for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width