Solved

Sort column when clicking header in DataViewGrid

Posted on 2009-04-04
3
241 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now