private void dataGridView1_Click(object sender, EventArgs e)
{
MouseEventArgs args = (MouseEventArgs)e;
DataGridView dgv = (DataGridView)sender;
DataGridView.HitTestInfo hit = dgv.HitTest(args.X, args.Y);
if (hit.Type == DataGridViewHitTestType.TopLeftHeader)
{
// Call sorting method
}
}
Ric wrote:
Datagridview - how to identify Top Left Corner Select All cell?
11-May-07
In a datagridview, the first column header cell is columnHeader(0), which is
immediately to the right of the Top Left Corner Select All cell. And the
first RowHeader cell is RowHeaderCell(0) which is immediately below the Top
Left Corner Select All cell
When clicking on the Top Left Corner SelectAll cell, which selects all the
Rows/columns in the datagridview, the only event that appears to fire is the
SelectionChanged event. But that event fires for just about anything. How
can I isolate/identify when it was the Top Left Corner SelectAll cell that
was clicked
Thanks
Rich
Previous Posts In This Thread:
Datagridview - how to identify Top Left Corner Select All cell?
In a datagridview, the first column header cell is columnHeader(0), which is
immediately to the right of the Top Left Corner Select All cell. And the
first RowHeader cell is RowHeaderCell(0) which is immediately below the Top
Left Corner Select All cell
When clicking on the Top Left Corner SelectAll cell, which selects all the
Rows/columns in the datagridview, the only event that appears to fire is the
SelectionChanged event. But that event fires for just about anything. How
can I isolate/identify when it was the Top Left Corner SelectAll cell that
was clicked
Thanks
Rich
Datagridview - how to identify Top Left Corner Select All cell?
You can superimpose a button on that corner cell and make it blend in with the DG so nobody knows it is there. I use it to toggle between SelectAll and ClearSelection.
Use the click event
Try this:
private void dataGridView1_Click(object sender, EventArgs e)
{
MouseEventArgs args = (MouseEventArgs)e;
DataGridView dgv = (DataGridView)sender;
DataGridView.HitTestInfo hit = dgv.HitTest(args.X, args.Y);
if (hit.Type == DataGridViewHitTestType.TopLeftHeader)
{
// do something here
}
}
DataGridView click top left cner
private void dataGridView1_Click(object sender, EventArgs e)
{
MouseEventArgs args = (MouseEventArgs)e;
DataGridView dgv = (DataGridView)sender;
DataGridView.HitTestInfo hit = dgv.HitTest(args.X, args.Y);
if (hit.Type == DataGridViewHitTestType.TopLeftHeader)
{
//Do something here
}
}
DataGridView click top left cner
private void dataGridView1_Click(object sender, EventArgs e)
{
MouseEventArgs args = (MouseEventArgs)e;
DataGridView dgv = (DataGridView)sender;
DataGridView.HitTestInfo hit = dgv.HitTest(args.X, args.Y);
if (hit.Type == DataGridViewHitTestType.TopLeftHeader)
{
//Do something here
}
}
Submitted via EggHeadCafe - Software Developer Portal of Choice
Displaying Popup RTF from embedded Resources
http://www.eggheadcafe.com/tutorial...1-191b7d398eb0/displaying-popup-rtf-from.aspx