Solved

Sort column when clicking header in DataViewGrid

Posted on 2009-04-04
3
245 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

707 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