Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. BindingSource position after table.AddRow(..)

BindingSource position after table.AddRow(..)

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpcssvisual-studiohelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mikepc
    wrote on last edited by
    #1

    Hi all, here is my problem: (system is VS 2005, C#, ADO .NET 2) I have a bindingsource, a datagrid, and set of details like fields on the same form. Next, there are following bindings set: void Init() { BindingSource.DataSource = someLocalTable datagrid.DataSource = BindingSource for every control { Control.DataBinding.Add("...", BindingSource, "...") } } Moving through a datagrid changes the data in bound detail controls, hence BindingSource too, changes position. Changing data in controls changes the data in selected dataGrid row. The problem is: I have a button "Insert New", that does exactly this: 1. adds a new row in the local someLocalTable and fills it with the default values: DataRow dr = someLocalTable.NewRow(); ... fill default values someLocalTable.Rows.Add(dr); 2. TRIES TO CHANGE THE BINDINGSOURCE-s POSITION TO LAST(newly created table row) 3. This is the step where after changing position on the bindingSource to the newly created row (.MoveLast()), you expect detail fields change to null (or empty), and dataGrid changes the ActiveRow and position However, after adding new row to someLocalTable, I can not change the position of the bindingSource to that new row. BindingSource.Count returns good nr. of rows, including the newly created. I tried a lots of things, like rebind all controls like on the Init method, still no luck. Am I missing something here? I forgot to mention that the grid is actually Infragistics ultraGrid, but that doesn't change the basic concept... Mike

    K 1 Reply Last reply
    0
    • M mikepc

      Hi all, here is my problem: (system is VS 2005, C#, ADO .NET 2) I have a bindingsource, a datagrid, and set of details like fields on the same form. Next, there are following bindings set: void Init() { BindingSource.DataSource = someLocalTable datagrid.DataSource = BindingSource for every control { Control.DataBinding.Add("...", BindingSource, "...") } } Moving through a datagrid changes the data in bound detail controls, hence BindingSource too, changes position. Changing data in controls changes the data in selected dataGrid row. The problem is: I have a button "Insert New", that does exactly this: 1. adds a new row in the local someLocalTable and fills it with the default values: DataRow dr = someLocalTable.NewRow(); ... fill default values someLocalTable.Rows.Add(dr); 2. TRIES TO CHANGE THE BINDINGSOURCE-s POSITION TO LAST(newly created table row) 3. This is the step where after changing position on the bindingSource to the newly created row (.MoveLast()), you expect detail fields change to null (or empty), and dataGrid changes the ActiveRow and position However, after adding new row to someLocalTable, I can not change the position of the bindingSource to that new row. BindingSource.Count returns good nr. of rows, including the newly created. I tried a lots of things, like rebind all controls like on the Init method, still no luck. Am I missing something here? I forgot to mention that the grid is actually Infragistics ultraGrid, but that doesn't change the basic concept... Mike

      K Offline
      K Offline
      Keith Malwitz
      wrote on last edited by
      #2

      I am not a CS programmer, but it sounds like you may need to call the ResetBindings method on your BindingSource control(s) prior to calling MoveLast. Hope this helps.

      M 1 Reply Last reply
      0
      • K Keith Malwitz

        I am not a CS programmer, but it sounds like you may need to call the ResetBindings method on your BindingSource control(s) prior to calling MoveLast. Hope this helps.

        M Offline
        M Offline
        mikepc
        wrote on last edited by
        #3

        No, I have tried that allready. Like I said, I tried to even mannualy reset bindings, still doesn't work. Thank You for trying... Mike

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups