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. Disable DataGridView auto selecting 1st row

Disable DataGridView auto selecting 1st row

Scheduled Pinned Locked Moved C#
csharpquestion
11 Posts 4 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.
  • G Offline
    G Offline
    Gavin Roberts
    wrote on last edited by
    #1

    hi all, I have a datagridview which when I populate it with data, the first row is selected by default. IIRC in .Net 1.1 the DataGrid never used to do this. Any one know how I can stop it? I've tried setting every row's Selected property to false. Thanks

    J J M 3 Replies Last reply
    0
    • G Gavin Roberts

      hi all, I have a datagridview which when I populate it with data, the first row is selected by default. IIRC in .Net 1.1 the DataGrid never used to do this. Any one know how I can stop it? I've tried setting every row's Selected property to false. Thanks

      J Offline
      J Offline
      Jabeerbe
      wrote on last edited by
      #2

      First Check whether u have write any code in the Rowbound. If not please check whether selectedIndex prrperty is set to -1. I hope this will solve ur problem

      Regards, A Jabeer Ali

      G 1 Reply Last reply
      0
      • J Jabeerbe

        First Check whether u have write any code in the Rowbound. If not please check whether selectedIndex prrperty is set to -1. I hope this will solve ur problem

        Regards, A Jabeer Ali

        G Offline
        G Offline
        Gavin Roberts
        wrote on last edited by
        #3

        there isn't a selectedIndex property and I haven't hooked any events as of yet.

        J 1 Reply Last reply
        0
        • G Gavin Roberts

          there isn't a selectedIndex property and I haven't hooked any events as of yet.

          J Offline
          J Offline
          Jabeerbe
          wrote on last edited by
          #4

          Sorry My friend. This Option is available in net.2005 for ASP:gridview. what version u r using?

          Regards, A Jabeer Ali

          G 1 Reply Last reply
          0
          • J Jabeerbe

            Sorry My friend. This Option is available in net.2005 for ASP:gridview. what version u r using?

            Regards, A Jabeer Ali

            G Offline
            G Offline
            Gavin Roberts
            wrote on last edited by
            #5

            .Net 2.0 with C# 2005. I am using a WinForms DataGridView.

            G 1 Reply Last reply
            0
            • G Gavin Roberts

              .Net 2.0 with C# 2005. I am using a WinForms DataGridView.

              G Offline
              G Offline
              Gavin Roberts
              wrote on last edited by
              #6

              I have tried ClearSelection and I have also set the selection mode to select a full row

              J 1 Reply Last reply
              0
              • G Gavin Roberts

                I have tried ClearSelection and I have also set the selection mode to select a full row

                J Offline
                J Offline
                Jabeerbe
                wrote on last edited by
                #7

                Check the Row Template for this Line DataGridViewRow { Index=-1 }

                Regards, A Jabeer Ali

                G 1 Reply Last reply
                0
                • J Jabeerbe

                  Check the Row Template for this Line DataGridViewRow { Index=-1 }

                  Regards, A Jabeer Ali

                  G Offline
                  G Offline
                  Gavin Roberts
                  wrote on last edited by
                  #8

                  And do what may I ask? I am unable to change it and the grid.RowTemplate.Index is read-only.

                  G 1 Reply Last reply
                  0
                  • G Gavin Roberts

                    And do what may I ask? I am unable to change it and the grid.RowTemplate.Index is read-only.

                    G Offline
                    G Offline
                    Gavin Roberts
                    wrote on last edited by
                    #9

                    I've found that ClearSelection will only work if I use the DataSource property.

                    1 Reply Last reply
                    0
                    • G Gavin Roberts

                      hi all, I have a datagridview which when I populate it with data, the first row is selected by default. IIRC in .Net 1.1 the DataGrid never used to do this. Any one know how I can stop it? I've tried setting every row's Selected property to false. Thanks

                      J Offline
                      J Offline
                      Jimmanuel
                      wrote on last edited by
                      #10

                      Try dataGridView1.ClearSelection(); after populating the grid with data. That should de-select anything that is selected.

                      1 Reply Last reply
                      0
                      • G Gavin Roberts

                        hi all, I have a datagridview which when I populate it with data, the first row is selected by default. IIRC in .Net 1.1 the DataGrid never used to do this. Any one know how I can stop it? I've tried setting every row's Selected property to false. Thanks

                        M Offline
                        M Offline
                        Member 7828804
                        wrote on last edited by
                        #11

                        DatagridView1.Rows(0).Selected = False

                        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