Selecting mutiple rows,cells or columns of a datagridview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ravitunk
    New Member
    • Jun 2007
    • 88

    Selecting mutiple rows,cells or columns of a datagridview

    hi..i have a datagridview in my windows application using C#......i want to select mutiple cells(by pressing shift key) or select mutiple columns or multiple rows.....if this happens then i should disable a button control....plz tell me what event gets fired if a user selects multiple cells or columns or rows..so tht i can write code to disable a button....plz reply back soon...thks for any assistance...
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Originally posted by ravitunk
    hi..i have a datagridview in my windows application using C#......i want to select mutiple cells(by pressing shift key) or select mutiple columns or multiple rows.....if this happens then i should disable a button control....plz tell me what event gets fired if a user selects multiple cells or columns or rows..so tht i can write code to disable a button....plz reply back soon...thks for any assistance...
    SelectionChange d is fired whenever the selection is changed at all. So, what you can do, is add an event handler for SelectionChange d. In this handler, check to see how many rows that are selected:

    Code:
    if(dataGridView1.SelectedRows.Count > 1)
    {
      //code for multiple selected cells
    }
    else
    {
      //code for 1 or 0 selected cells
    }

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      This could have been solved very easily if you had bothered to do any work looking for it.
      Try actually LOOKING at your object, or even at MSDN

      Comment

      Working...