dataGrid[ hti.Row, hti.Column ] = ! (bool) dataGrid[ hti.Row, hti.Column ]

J

Jason Huang

Hi,

In the code:

DataGrid.HitTestInfo hti = dataGrid.HitTest( e.X, e.Y );
dataGrid[ hti.Row, hti.Column ] = ! (bool) dataGrid[ hti.Row, hti.Column ];

Would someone tell me what the line doing:
DataGrid.HitTestInfo hti = dataGrid.HitTest( e.X, e.Y );

Thanks.

Jason
 
G

Guest

Hello,
This method would be use in a Click Event. It gives information about the
System.Windows.Forms.DataGrid control at a specified point on the screen. e
is the point you have clicked. DataGridHitTest give you the the Clicked
Cell.

Example:

private void dataGrid1_MouseUp(System.Windows.Forms.MouseEventArgs e)
{
DataGrid.HitTestInfo hti = this.HitTest(new Point(e.X, e.Y));
switch(hti.Type)
{
case DataGrid.HitTestType.RowHeader:
//RowHeader was clicked
break;

case DataGrid.HitTestType.ColumnHeader:
//ColumnHeader was clicked
break;

case DataGrid.HitTestType.Cell:
//a Cell was clicked
break;
}
}

http://msdn2.microsoft.com/en-us/library/system.windows.forms.datagrid.hittest.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top