Results 1 to 8 of 8

Thread: Data Binding stuffing up through Designer???

  1. #1

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Data Binding stuffing up through Designer???

    I drag a field in from the datasources and it creates a bindingsource for it in the components section and binds the text field to it... when I then drag another filed from the same datasource onto the form it then creates another bindingsource for this filed instead of using the existing one???

    Also on further inspection databindings/text property for the textbox is: "ResTreatmentsBindingSource1 - Desc", but when i drop down the property editor, i cannot expand the bindingsource's (ResTreatmentsBindingSource1) fields???

    What is going on here? VS just started doing this...

    Thanks,
    Kris

  2. #2

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Re: Data Binding stuffing up through Designer???

    ...
    Also when i delete the \bin things start working ... but only until i run or build the project again.

    Thanks,
    Kris

  3. #3
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Data Binding stuffing up through Designer???

    VS just started doing this...
    Er ... no ... it didn't. It's doing what it's always done and what it should do, ie. creating a binding source for each control. This is so that you can have a single column from a table bound to two or more different controls (should you so desire) or individual values in a set of controls whilst simultaneously displaying the full table in DGV, for example.

    Also why would you expect to be able to expand the fields for a binding source that, by definition, only has one field, as a textbox's source must?

    These are simply the things that using design time bindings requires. If you find them inconvenient (and I don't blame you in the least if you do) learn to program for database interaction runtime. There are hundreds of tutorials about including a few very good ones in this forum's Codebank.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Data Binding stuffing up through Designer???

    Don't drag the columns from the Data Sources window one by one. As dunfiddlin says, the IDE will create a separate BindingSource for each one, exactly as it should. If you want one BindingSource for multiple columns in one table then you need to drag the table from the Data Sources window, not the columns. By default, a table will generate a DataGridView when dragged from the Data Sources window but you can change that to details view, i.e. discrete controls for each column. You can then delete the controls for the fields that you don't want to display.

    Alternatively, if you already have a BindingSource then just don't drag anything from the Data Sources window. Simply add the appropriate control yourself and then bind it to the existing BindingSource via the Properties window.

  5. #5

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Re: Data Binding stuffing up through Designer???

    As i said before ... "i cannot expand the bindingsource's (ResTreatmentsBindingSource1) fields"

    Before delete obj folders:



    And after i delete the obj folders:



    Any ideas? ... this is just frustrating

    Thanks,
    Kris

  6. #6

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Re: Data Binding stuffing up through Designer???

    Quote Originally Posted by jmcilhinney View Post
    Don't drag the columns from the Data Sources window one by one. As dunfiddlin says, the IDE will create a separate BindingSource for each one, exactly as it should. If you want one BindingSource for multiple columns in one table then you need to drag the table from the Data Sources window, not the columns. By default, a table will generate a DataGridView when dragged from the Data Sources window but you can change that to details view, i.e. discrete controls for each column. You can then delete the controls for the fields that you don't want to display.

    Alternatively, if you already have a BindingSource then just don't drag anything from the Data Sources window. Simply add the appropriate control yourself and then bind it to the existing BindingSource via the Properties window.
    And actually both of you appear to be incorrect ... when i drag multiple fields from the same datasource it DOES NOT create multiple binding sources ... it just uses the one that is already on my form; it only creates multiple when i cannot view the fields in the binding source in the properties window (before i delete the obj folder)

    Kris

  7. #7
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Data Binding stuffing up through Designer???

    And actually both of you appear to be incorrect ... when i drag multiple fields from the same datasource it DOES NOT create multiple binding sources
    Well we would be, if either of us had actually said anything of the sort!
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  8. #8

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Re: Data Binding stuffing up through Designer???

    Quote Originally Posted by dunfiddlin View Post
    Well we would be, if either of us had actually said anything of the sort!
    You said "It's doing what it's always done and what it should do, ie. creating a binding source for each control" ... this isn't the case though, if I drag multiple fields from the same datasource it does not behave this way and just creates just one binding source for that datasource and uses that for the multiple controls... and does not "create a binding source for each control"

    Kris

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