BindingSource_PositionChanged

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Miro

    BindingSource_PositionChanged

    I don't seem to understand the timing of some events.

    I have a datagridview bound to a binding source.

    When I click on a different row within the datagridview, the
    BindingSource_P ositionChanged gets fired and also the
    CurrentCellChan ged gets fired.

    My problem is that, when the BindingSource_P ositionChanged fires, the
    Me.DataGrid.Cur rentRow.Index is still pointing to the old pointer.

    For example I have 4 rows in the datagridview.

    Row 1
    Row 2 <- Cursor is here
    Row 3 <-Cursor will be moved here
    Row 4

    When the cursor is moved, the Me.DataGrid.Cur rentRow.Index still points to
    row 2 and not 3.

    Whats the point of using Me.DataGrid.Cur rentRow.Index when it is not the
    value it really is?

    Miro

  • Jack Jackson

    #2
    Re: BindingSource_P ositionChanged

    On Fri, 17 Oct 2008 16:05:32 -0400, "Miro" <miro@beero.com wrote:
    >I don't seem to understand the timing of some events.
    >
    >I have a datagridview bound to a binding source.
    >
    >When I click on a different row within the datagridview, the
    >BindingSource_ PositionChanged gets fired and also the
    >CurrentCellCha nged gets fired.
    >
    >My problem is that, when the BindingSource_P ositionChanged fires, the
    >Me.DataGrid.Cu rrentRow.Index is still pointing to the old pointer.
    >
    >For example I have 4 rows in the datagridview.
    >
    >Row 1
    >Row 2 <- Cursor is here
    >Row 3 <-Cursor will be moved here
    >Row 4
    >
    >When the cursor is moved, the Me.DataGrid.Cur rentRow.Index still points to
    >row 2 and not 3.
    >
    >Whats the point of using Me.DataGrid.Cur rentRow.Index when it is not the
    >value it really is?
    >
    >Miro
    Since the BindingSource position and the DataGridView position are
    separate things, I don't think you will be able to reliably get
    correct information from one of them in the event handler for the
    other.

    You could use the changing event of the DataGridView and look at
    CurrentRow in that, or the changing event of the BindingSource and its
    Position value.

    Comment

    • Miro

      #3
      Re: BindingSource_P ositionChanged

      Yeah I was just surprised because,

      If I click on the datagridview to a new row,
      the cursor is at the new row,
      the bindingsource event hits first, but if you debug.writeline the
      datagrid.curren trow.index, it is still at the old row.

      All part of learning i guess -

      Thanks

      Miro

      "Jack Jackson" <jjackson@cinno vations.netwrot e in message
      news:7h7if4dfva c0qi15onj6mi7l1 lvkpv7pji@4ax.c om...
      On Fri, 17 Oct 2008 16:05:32 -0400, "Miro" <miro@beero.com wrote:
      >
      >>I don't seem to understand the timing of some events.
      >>
      >>I have a datagridview bound to a binding source.
      >>
      >>When I click on a different row within the datagridview, the
      >>BindingSource _PositionChange d gets fired and also the
      >>CurrentCellCh anged gets fired.
      >>
      >>My problem is that, when the BindingSource_P ositionChanged fires, the
      >>Me.DataGrid.C urrentRow.Index is still pointing to the old pointer.
      >>
      >>For example I have 4 rows in the datagridview.
      >>
      >>Row 1
      >>Row 2 <- Cursor is here
      >>Row 3 <-Cursor will be moved here
      >>Row 4
      >>
      >>When the cursor is moved, the Me.DataGrid.Cur rentRow.Index still points to
      >>row 2 and not 3.
      >>
      >>Whats the point of using Me.DataGrid.Cur rentRow.Index when it is not the
      >>value it really is?
      >>
      >>Miro
      >
      Since the BindingSource position and the DataGridView position are
      separate things, I don't think you will be able to reliably get
      correct information from one of them in the event handler for the
      other.
      >
      You could use the changing event of the DataGridView and look at
      CurrentRow in that, or the changing event of the BindingSource and its
      Position value.

      Comment

      Working...