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. C#
  4. DataGrid Event

DataGrid Event

Scheduled Pinned Locked Moved C#
csharpquestion
11 Posts 3 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 Mazdak

    I have a DataGrid,I need the event that raise,when a user DbClick on a cell or row,But I can't find it,Does anything like this exist in C# or any solution for it? Thanks Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
    Wish You Were Here-Pink Floyd-1975

    A Offline
    A Offline
    Andres Manggini
    wrote on last edited by
    #2

    Would this work (not tested)? Control.DoubleClick Event [C#] public event EventHandler DoubleClick; Event Data The event handler receives an argument of type EventArgs containing data related to this event. Remarks The ControlStyles.StandardClick style must be set for this event to be raised. Andres Manggini. Buenos Aires - Argentina.

    M 1 Reply Last reply
    0
    • A Andres Manggini

      Would this work (not tested)? Control.DoubleClick Event [C#] public event EventHandler DoubleClick; Event Data The event handler receives an argument of type EventArgs containing data related to this event. Remarks The ControlStyles.StandardClick style must be set for this event to be raised. Andres Manggini. Buenos Aires - Argentina.

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

      Andres Manggini wrote: Control.DoubleClick Event No,this raised when you double click on fixed column or cells,not regular cells.I think there is solution and thats when you want to edit a cell you have to DbClick on that cell,Do you know what event raised when it goes into edit mode? Andres Manggini wrote: Remarks The ControlStyles.StandardClick style must be set for this event to be raised. Where is that?I couldn't find it. Thanks Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
      Wish You Were Here-Pink Floyd-1975

      A J 2 Replies Last reply
      0
      • M Mazdak

        Andres Manggini wrote: Control.DoubleClick Event No,this raised when you double click on fixed column or cells,not regular cells.I think there is solution and thats when you want to edit a cell you have to DbClick on that cell,Do you know what event raised when it goes into edit mode? Andres Manggini wrote: Remarks The ControlStyles.StandardClick style must be set for this event to be raised. Where is that?I couldn't find it. Thanks Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
        Wish You Were Here-Pink Floyd-1975

        A Offline
        A Offline
        Andres Manggini
        wrote on last edited by
        #4

        mmm.. I don't know, I'll see if i look into it. this documentation is from MSDN (the one which comes with Visual Studio.NET Enterprise Edition). Andres Manggini. Buenos Aires - Argentina.

        M 1 Reply Last reply
        0
        • A Andres Manggini

          mmm.. I don't know, I'll see if i look into it. this documentation is from MSDN (the one which comes with Visual Studio.NET Enterprise Edition). Andres Manggini. Buenos Aires - Argentina.

          M Offline
          M Offline
          Mazdak
          wrote on last edited by
          #5

          Andres Manggini wrote: this documentation is from MSDN (the one which comes with Visual Studio.NET Enterprise Edition). Sorry,Which documentation you mean? Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
          Wish You Were Here-Pink Floyd-1975

          A 1 Reply Last reply
          0
          • M Mazdak

            Andres Manggini wrote: this documentation is from MSDN (the one which comes with Visual Studio.NET Enterprise Edition). Sorry,Which documentation you mean? Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
            Wish You Were Here-Pink Floyd-1975

            A Offline
            A Offline
            Andres Manggini
            wrote on last edited by
            #6

            Microsoft Visual Studio.NET Documentation. a blue ballon icon, with a question mark inside of it :) Regards, Andres Manggini. Buenos Aires - Argentina.

            1 Reply Last reply
            0
            • M Mazdak

              Andres Manggini wrote: Control.DoubleClick Event No,this raised when you double click on fixed column or cells,not regular cells.I think there is solution and thats when you want to edit a cell you have to DbClick on that cell,Do you know what event raised when it goes into edit mode? Andres Manggini wrote: Remarks The ControlStyles.StandardClick style must be set for this event to be raised. Where is that?I couldn't find it. Thanks Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
              Wish You Were Here-Pink Floyd-1975

              J Offline
              J Offline
              James T Johnson
              wrote on last edited by
              #7

              ControlStyles is an enumeration. Each control has one and can be set via the SetStyles() protected method on a control. You pass in the flags you want to set/unset and pass in true or false to tell whether it should set that style. HTH, James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

              M 1 Reply Last reply
              0
              • J James T Johnson

                ControlStyles is an enumeration. Each control has one and can be set via the SetStyles() protected method on a control. You pass in the flags you want to set/unset and pass in true or false to tell whether it should set that style. HTH, James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

                M Offline
                M Offline
                Mazdak
                wrote on last edited by
                #8

                Can you give an example please? Thanks:) Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
                Wish You Were Here-Pink Floyd-1975

                J 1 Reply Last reply
                0
                • M Mazdak

                  Can you give an example please? Thanks:) Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
                  Wish You Were Here-Pink Floyd-1975

                  J Offline
                  J Offline
                  James T Johnson
                  wrote on last edited by
                  #9

                  Usually you set it in the controls constructor so

                  public class myDataGrid : DataGrid {
                  public myDataGrid() {
                  SetStyle( ControlStyles.StandardClick, true );
                  }
                  }

                  Now the Double click events will fire according to the documentation. I can't tell from the documentation if the DoubleClick event will fire for everything now or if it was supposed to indicate the standard event will fire. In anycase you should be able to hook into the DoubleClick event yourself and do some calculating to determine which cell is being clicked on. James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

                  M 1 Reply Last reply
                  0
                  • J James T Johnson

                    Usually you set it in the controls constructor so

                    public class myDataGrid : DataGrid {
                    public myDataGrid() {
                    SetStyle( ControlStyles.StandardClick, true );
                    }
                    }

                    Now the Double click events will fire according to the documentation. I can't tell from the documentation if the DoubleClick event will fire for everything now or if it was supposed to indicate the standard event will fire. In anycase you should be able to hook into the DoubleClick event yourself and do some calculating to determine which cell is being clicked on. James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

                    M Offline
                    M Offline
                    Mazdak
                    wrote on last edited by
                    #10

                    hmmm,So I have to use subclassing,I never do that in C#,Can you tell me how?Is this right: Create new class derived from DataGrid class and handle DoubleClick() event. Then I don't know how to use it in my application. Thanks:) Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
                    Wish You Were Here-Pink Floyd-1975

                    J 1 Reply Last reply
                    0
                    • M Mazdak

                      hmmm,So I have to use subclassing,I never do that in C#,Can you tell me how?Is this right: Create new class derived from DataGrid class and handle DoubleClick() event. Then I don't know how to use it in my application. Thanks:) Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
                      Wish You Were Here-Pink Floyd-1975

                      J Offline
                      J Offline
                      James T Johnson
                      wrote on last edited by
                      #11

                      Yep thats correct, using a subclassed control is easy; instead of saying System.Windows.Forms.DataGrid, you refer to myDataGrid :) Thats all there is to it. James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

                      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