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. Help with datagridview ...

Help with datagridview ...

Scheduled Pinned Locked Moved C#
helptutorialquestion
9 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.
  • T Offline
    T Offline
    turbosupramk3
    wrote on last edited by
    #1

    Datagridview is harder than I anticipated. I would like to click on my column header and select an entire column to change it, or click on my row header and select an entire row to change it, or select multiple cells to change them or a single cell to change it. Is this possible with the datagridview object? If so, does anyone have a code example? I've been looking over the net and I'm able to get the column selection to work most of the time, but apparently that disables row selection and I would like both of them, depending on which header is clicked? Thanks for reading.

    L M T 3 Replies Last reply
    0
    • T turbosupramk3

      Datagridview is harder than I anticipated. I would like to click on my column header and select an entire column to change it, or click on my row header and select an entire row to change it, or select multiple cells to change them or a single cell to change it. Is this possible with the datagridview object? If so, does anyone have a code example? I've been looking over the net and I'm able to get the column selection to work most of the time, but apparently that disables row selection and I would like both of them, depending on which header is clicked? Thanks for reading.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Check the different events available at http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview%28v=vs.110%29.aspx[^]. Without more detail it is not possible to know why it does not work for you.

      1 Reply Last reply
      0
      • T turbosupramk3

        Datagridview is harder than I anticipated. I would like to click on my column header and select an entire column to change it, or click on my row header and select an entire row to change it, or select multiple cells to change them or a single cell to change it. Is this possible with the datagridview object? If so, does anyone have a code example? I've been looking over the net and I'm able to get the column selection to work most of the time, but apparently that disables row selection and I would like both of them, depending on which header is clicked? Thanks for reading.

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        I think your requirements sound a little ambitious for the DGV, it sounds like you are more after spreadsheet like functionality which you will not get out of a DGV. You might have to look into some of the spreadsheet controls, none of which are free or even cheap.

        Never underestimate the power of human stupidity RAH

        1 Reply Last reply
        0
        • T turbosupramk3

          Datagridview is harder than I anticipated. I would like to click on my column header and select an entire column to change it, or click on my row header and select an entire row to change it, or select multiple cells to change them or a single cell to change it. Is this possible with the datagridview object? If so, does anyone have a code example? I've been looking over the net and I'm able to get the column selection to work most of the time, but apparently that disables row selection and I would like both of them, depending on which header is clicked? Thanks for reading.

          T Offline
          T Offline
          turbosupramk3
          wrote on last edited by
          #4

          Is there any way to select a cell and then if the enter key is pressed, have an input box pop up to input a value. Then taking it further, select multiple cells, press the enter key, input box pops up and you can set that same value for all selected cells? Is this possible in the datagridview object?

          L 1 Reply Last reply
          0
          • T turbosupramk3

            Is there any way to select a cell and then if the enter key is pressed, have an input box pop up to input a value. Then taking it further, select multiple cells, press the enter key, input box pops up and you can set that same value for all selected cells? Is this possible in the datagridview object?

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            If you had followed my earlier suggestion and looked at the properties in the documentation, you would have spotted MultiSelect[^].

            T 1 Reply Last reply
            0
            • L Lost User

              If you had followed my earlier suggestion and looked at the properties in the documentation, you would have spotted MultiSelect[^].

              T Offline
              T Offline
              turbosupramk3
              wrote on last edited by
              #6

              I did follow your suggestion. That doesn't mean it gives a working code example that I can insert into my form and start to figure out its intricacies. I can't even get the event handlers to work with this object, it tells me the following error for the following code? Error 4 Cannot implicitly convert type 'System.Windows.Forms.DataGridViewCellEventHandler' to 'System.EventHandler' c:\Form1.cs 51 47 this.dataGridView1.CellClick += new DataGridViewCellEventHandler(dataGridView1_CellClick); // works this.dataGridView1.DoubleClick += new DataGridViewCellEventHandler(dataGridView1_CellDoubleClick); // generates the above error

              L 1 Reply Last reply
              0
              • T turbosupramk3

                I did follow your suggestion. That doesn't mean it gives a working code example that I can insert into my form and start to figure out its intricacies. I can't even get the event handlers to work with this object, it tells me the following error for the following code? Error 4 Cannot implicitly convert type 'System.Windows.Forms.DataGridViewCellEventHandler' to 'System.EventHandler' c:\Form1.cs 51 47 this.dataGridView1.CellClick += new DataGridViewCellEventHandler(dataGridView1_CellClick); // works this.dataGridView1.DoubleClick += new DataGridViewCellEventHandler(dataGridView1_CellDoubleClick); // generates the above error

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                DataGridView does not have a DoubleClick event, it is inherited from Control. You should be using CellDoubleClick or use the approprite casting for double clicking of the entire form.

                T 1 Reply Last reply
                0
                • L Lost User

                  DataGridView does not have a DoubleClick event, it is inherited from Control. You should be using CellDoubleClick or use the approprite casting for double clicking of the entire form.

                  T Offline
                  T Offline
                  turbosupramk3
                  wrote on last edited by
                  #8

                  Thank you, celldoubleclick worked. With multiselect, that appears to just be a property that you enable or disable. If enabled, how can I know which cells I've selected? Then I could input the data for the select cells with a right click command possibly?

                  L 1 Reply Last reply
                  0
                  • T turbosupramk3

                    Thank you, celldoubleclick worked. With multiselect, that appears to just be a property that you enable or disable. If enabled, how can I know which cells I've selected? Then I could input the data for the select cells with a right click command possibly?

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    turbosupramk3 wrote:

                    how can I know which cells I've selected?

                    Once again, go and look at the documentation, see what information you get presented with by the different events.

                    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