By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,963 Members | 1,778 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,963 IT Pros & Developers. It's quick & easy.

Selecting mutiple rows,cells or columns of a datagridview

P: 88
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...
May 24 '08 #1
Share this Question
Share on Google+
2 Replies


Curtis Rutland
Expert 2.5K+
P: 3,256
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...
SelectionChanged is fired whenever the selection is changed at all. So, what you can do, is add an event handler for SelectionChanged. In this handler, check to see how many rows that are selected:

Expand|Select|Wrap|Line Numbers
  1. if(dataGridView1.SelectedRows.Count > 1)
  2. {
  3.   //code for multiple selected cells
  4. }
  5. else
  6. {
  7.   //code for 1 or 0 selected cells
  8. }
  9.  
May 24 '08 #2

Plater
Expert 5K+
P: 7,872
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
May 27 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.