DataGridView - how to find out a selected cells

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lopy
    New Member
    • Dec 2007
    • 8

    DataGridView - how to find out a selected cells

    Hi, Can anybody tell me how Can I find out a indexes of cells which are selected? E.g: when I want to delete a content a cells.
    thanx
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    For a DataGridView, an event is fired on cell selection, the event gives you the information you need.

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      Originally posted by Plater
      For a DataGridView, an event is fired on cell selection, the event gives you the information you need.
      The event pass you a variable "e". This variable will contains the properties that you are looking for.
      Last edited by Frinavale; Dec 21 '07, 04:30 PM. Reason: Fixed my sentence so it made sense...

      Comment

      • Lopy
        New Member
        • Dec 2007
        • 8

        #4
        Thanx a lot:]............... .....

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          Not to mention there is a "SelectedCe lls" object that gives you all the information you need.

          Which leads me to believe you put in zero effort before asking the question.

          Comment

          • Lopy
            New Member
            • Dec 2007
            • 8

            #6
            I looking for a proper event but I dind't find one. May by MultiSelectChan ged but here I don't have any proper method which tell me a selected cells. Do you tell me this method psl...

            Comment

            • Plater
              Recognized Expert Expert
              • Apr 2007
              • 7872

              #7
              Events:
              SelectionChange d gets fired when the selection changes(Will need to use SelectedCells to get information)
              CellMouseClick gets fired when a cell is clicked.
              CellMouseDouble Click gets fired when a cell is double-clicked
              CellContentClic k gets fired when the contents of a cell are clicked(i.e. a button in a cell)

              Almost any event can give you the information you request....

              Properties:
              .SelectedCells gives the collection of cells currently selected.
              .SelectedRows gives the collection of rows currently selected

              Comment

              • Lopy
                New Member
                • Dec 2007
                • 8

                #8
                An event SelectedCells don't give a selected cells. SelectedCells.C ount give me a count of selected cells. Any proper method or properties don't return an int value. If I make anywhere mistake, do you tell me a correct solution pls.

                Comment

                • Plater
                  Recognized Expert Expert
                  • Apr 2007
                  • 7872

                  #9
                  SelectedCells is a COLLECTION.
                  SelectedCells[0] is the first selected cell (if exists)
                  SelectedCells[1] is the second selected cell (if exists)
                  etc


                  If you are having trouble with these things, I recomend reading up on some tutorials

                  Comment

                  • Lopy
                    New Member
                    • Dec 2007
                    • 8

                    #10
                    oh. OK. great..........

                    Comment

                    Working...