Home Forums WinForms controls Xceed Grid for WinForms Bidirectional BindingSource position change

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #16732 |

    (I posted this earlier but for some reason it was moved to the WPF forum.  This refers to the Windows Forms .NET version of the grid control) 

    When I select a row on my grid the bound BindingSource position changes. 

    When I change the position in the BindingSource, the selected row in the grid is not updated.  What is the best way to select a row based on the BindingSource position?

    Thanks,

    Justin

    Imported from legacy forums. Posted by Justin (had 947 views)

    User (Old forums)
    Member
    Post count: 23064

    Sorry about the post being moved.

    The grid updates correctly when the current row changes in the binding source.  The problem is that only the CurrentRow property is being updated, not the SelectedRows collection (expected behavior because these are independent properties), which means that the selection will not update in the grid.

    So what you can do is to subscribe to the CurrentRowChanged event, and in the event handler, set the SelectedRows collection.

    e.g.:

        private void Form1_Load( object sender, EventArgs e )
        {
          gridControl1.CurrentRowChanged += new EventHandler( gridControl1_CurrentRowChanged );
        }

        void gridControl1_CurrentRowChanged( object sender, EventArgs e )
        {
          if( gridControl1.CurrentRow != null )
          {
            gridControl1.SelectedRows.Clear();
            gridControl1.SelectedRows.Add( gridControl1.CurrentRow );
          }
        }

    Imported from legacy forums. Posted by André (had 859 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.