DataGrid CurrentRowChanged ?

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

    #1

    DataGrid CurrentRowChanged ?

    Hello,

    The DataGrid.Curren tCellChanged requires too much overhead to determine when
    only the row has changed.

    Can anyone suggest a way to fire an event when the user selects a different
    row in a windows forms datagrid?

    Perhaps this can be done by examining the underlying DataTable, but I'm yet
    to find a way.

    Thanks




  • Jazper

    #2
    Re: DataGrid CurrentRowChang ed ?

    hi paul

    the datagrid itself does not have such an event... i guess!
    however the DataTable has them!

    myDataTable.Row Changed
    myDataTable.Row Changing
    myDataTable.Row Deleted
    myDataTable.Row Deleting

    just map these events to a method in your class, and event will fire when
    datarow changed on the datagrid!

    hope this helps
    cheers Jazper


    "Paul Sampson" <psampson@uecom m.com.au> schrieb im Newsbeitrag
    news:1068683587 .53756@proxy.ue comm.net.au...[color=blue]
    > Hello,
    >
    > The DataGrid.Curren tCellChanged requires too much overhead to determine[/color]
    when[color=blue]
    > only the row has changed.
    >
    > Can anyone suggest a way to fire an event when the user selects a[/color]
    different[color=blue]
    > row in a windows forms datagrid?
    >
    > Perhaps this can be done by examining the underlying DataTable, but I'm[/color]
    yet[color=blue]
    > to find a way.
    >
    > Thanks
    >
    >
    >
    >[/color]


    Comment

    • Dmitriy Lapshin [C# / .NET MVP]

      #3
      Re: DataGrid CurrentRowChang ed ?

      Hi Paul,

      The simplest (and the most reliable I believe) way would be to override the
      OnCurrentCellCh anged method in a class inherited from the DataGrid and raise
      a custom CurrentRowChang ed event whenever the user goes to another row (you
      can determine that by analyzing the CurrentCell property and maintaining a
      temporary variable storing current row number).

      --
      Dmitriy Lapshin [C# / .NET MVP]
      X-Unity Test Studio

      Bring the power of unit testing to VS .NET IDE

      "Paul Sampson" <psampson@uecom m.com.au> wrote in message
      news:1068683587 .53756@proxy.ue comm.net.au...[color=blue]
      > Hello,
      >
      > The DataGrid.Curren tCellChanged requires too much overhead to determine[/color]
      when[color=blue]
      > only the row has changed.
      >
      > Can anyone suggest a way to fire an event when the user selects a[/color]
      different[color=blue]
      > row in a windows forms datagrid?
      >
      > Perhaps this can be done by examining the underlying DataTable, but I'm[/color]
      yet[color=blue]
      > to find a way.
      >
      > Thanks
      >
      >
      >
      >[/color]

      Comment

      Working...