Solved

Sort column when clicking header in DataViewGrid

Posted on 2009-04-04
3
243 Views
Last Modified: 2013-11-27
I have a DataGridView that pops up a dialog when a cell is clicked. The dialog displays information relevant to the selected row.

If I click the column header, the dialog is displayed even though I only want the DataGridView to be sorted. Once I close the dialog, the DataGRidView is displayed sorted.

How can I avoid displaying the dialog when the column header is displayed?
0
Comment
Question by:jindalee
  • 2
3 Comments
 
LVL 6

Expert Comment

by:Ramone_Hamilton
ID: 24070585
In which event are you calling your method to dsplay the dialog?
0
 
LVL 6

Accepted Solution

by:
Ramone_Hamilton earned 500 total points
ID: 24070639
Here's an example of how you can fix this.  I'm assuming you are usin the CellContentClick even.  Simple add an if check for e.RowIndex == -1, which represents the headerrow.
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
            }
            else
            {
                MessageBox.Show("Hello");
            }
        }

Open in new window

0
 
LVL 1

Author Closing Comment

by:jindalee
ID: 31566710
I'm using VB but is was easy to translate the C into VB

if e.RowIndex > -1 then
    do stuff
end if

Thank you
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Exceptions 3 44
What do you call this line of code in this .NET Core page? 4 34
How to prevent website from publishing with errors 9 47
No Data for DropDown List 2 25
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question