in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

SetDataBinding and Databound controls

Last post 09-11-2008 9:30 AM by Jigabyte. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 01-23-2008 5:00 PM

    SetDataBinding and Databound controls

    Hopefully I'm just making a mistake somewhere. Here is my setup. I have a truegrid control with 2 columns (username and last name) and I have 3 textboxes for username, last name and first name.

    First, in code, I databind a datatable to the truegrid using the datasource property.

    Next I databind the same datatable to the textboxes.

    The form loads and when I select a row (or cell of a row) in the truegrid the texboxes update and change to show the bound columns of the newly selected row. i.e. I click fSlacker and Fred Slacker shows up in the textboxes below.

    However, the design time columns are ignored and the entire table I'm loading shows up in the grid.

    So, I replace the first step in my code with: TrueGridInstance.SetDataBinding(DataSetInstance, "tablename", true)

    And recompile the project.
     
    The form loads and the truegrid looks correct (only two columns show) and fills with data. But, when I select a row ( or cell of a row ) the textboxes do Not update and change to show the bound columns of the newly selected row. i.e, I click fSlacker and Joan Arc (first entry in the datatable) always displays in the textboxes.

    So, to recap, if I use the truegrid's DataSource property the other bound controls behave "correctly" but if I use SetDataBinding, they don't. Is there a bug or am I using the SetDataBinding incorrectly or is SetDataBinding just Not meant to work in this way? I really wanted to use the TrueGrid for it's filter row features but I don't want to re-write how our data schema is done just for that.

    Any help would be greatly appreciated and I hope I'm just doing something wrong.

    Here's the code that doesn't work:

    With usr.Dataset_UserGroupMgr
                C1TrueDBGrid1.SetDataBinding(usr.Dataset_UserGroupMgr.Tables("UserList"), "UserList", True)
                txtUserName.DataBindings.Add("text", .Tables("UserList"), "sUserName")
                txtFirstName.DataBindings.Add("text", .Tables("UserList"), "sFirst")
                txtLastName.DataBindings.Add("text", .Tables("UserList"), "sLast")
    End With

    Heres the code that does :

    With usr.Dataset_UserGroupMgr
                C1TrueDBGrid1.DataSource = .Tables("UserList")
                txtUserName.DataBindings.Add("text", .Tables("UserList"), "sUserName")
                txtFirstName.DataBindings.Add("text", .Tables("UserList"), "sFirst")
                txtLastName.DataBindings.Add("text", .Tables("UserList"), "sLast")
    End With
     


     

  • 01-24-2008 9:23 AM In reply to

    Re: SetDataBinding and Databound controls

    The TrueDBGrid version I'm using is 2.0.20073.61130.

  • 01-28-2008 3:38 PM In reply to

    Re: SetDataBinding and Databound controls

    Hi

     

    Attached is a sample which performs the same functions as you desire, using SetDataBinding.

     

    Regards

    Andrew

     

     
    <thibblen> wrote in message news:201316@10.0.1.98...

    The TrueDBGrid version I'm using is 2.0.20073.61130.



    http://helpcentral.componentone.com/cs/forums/p/74099/201316.aspx#201316

  • 09-11-2008 9:30 AM In reply to

    Re: SetDataBinding and Databound controls

    Hi,

     The example works great and is just what I want to do, BUT! Why when I manuall create a dataadapter / dataset and use the setdatabinding does the dataset get out of sync if I use the sort or filter on the grid?

    Thanks for any advice,

    Roger

Page 1 of 1 (4 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.