Overriding DataGrid behaviour

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

    Overriding DataGrid behaviour

    Hi!

    I'm using DataGrid in windows form.
    I need to implement the following functionality:
    - any mouse must select a row according where mouse has been clicked
    - context menu must be also availiable by right mouse click

    Have you got any ideas?
    Thanks for any advice.


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Overriding DataGrid behaviour

    Dmitry,

    The context menu is easy, just create a menu and assign it to the
    ContextMenu property of the DataGrid control. To select a complete row, you
    can handle the click event of a grid and then use the Select method to
    select a particular row. To get the row that was clicked, you can use the
    HitTest method to find out where the row is that was clicked on.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Dmitry Karneyev" <karneyev@msn.c om> wrote in message
    news:e0%23VPcgo DHA.2732@TK2MSF TNGP11.phx.gbl. ..[color=blue]
    > Hi!
    >
    > I'm using DataGrid in windows form.
    > I need to implement the following functionality:
    > - any mouse must select a row according where mouse has been clicked
    > - context menu must be also availiable by right mouse click
    >
    > Have you got any ideas?
    > Thanks for any advice.
    >
    >[/color]


    Comment

    • Dmitry Karneyev

      #3
      Re: Overriding DataGrid behaviour

      Thanks Nicholas!
      That is exact I've been looking for.

      "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om>
      ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ:
      news:OO1v2UhoDH A.2512@TK2MSFTN GP09.phx.gbl...[color=blue]
      > Dmitry,
      >
      > The context menu is easy, just create a menu and assign it to the
      > ContextMenu property of the DataGrid control. To select a complete row,[/color]
      you[color=blue]
      > can handle the click event of a grid and then use the Select method to
      > select a particular row. To get the row that was clicked, you can use the
      > HitTest method to find out where the row is that was clicked on.
      >
      > Hope this helps.
      >
      >
      > --
      > - Nicholas Paldino [.NET/C# MVP]
      > - mvp@spam.guard. caspershouse.co m
      >
      > "Dmitry Karneyev" <karneyev@msn.c om> wrote in message
      > news:e0%23VPcgo DHA.2732@TK2MSF TNGP11.phx.gbl. ..[color=green]
      > > Hi!
      > >
      > > I'm using DataGrid in windows form.
      > > I need to implement the following functionality:
      > > - any mouse must select a row according where mouse has been clicked
      > > - context menu must be also availiable by right mouse click
      > >
      > > Have you got any ideas?
      > > Thanks for any advice.
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...