We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

GridHitTestContext

Hi, Would you have some code snippet which shows how to know if the mouse is over a cell, a header cell, ... in a grid control. Thank''s in advance Louis

6 Replies

AD Administrator Syncfusion Team October 15, 2004 04:58 AM UTC

Here is code that gives you the row and col index of the hit. From there you would compare these values against grid.Cols.HeaderCount or grid.Rows.HeaderCount to decide whether the cell was a header or not. //get the point somehow //could possible use event args here //but make sure the point is in the grid''s coordinates Point pt = grid.PointToClient(Control.MousePosition); if(grid.PointToRowCol(pt, out row, out col, -1)) { // row and col now hold their values }


LO Louis October 15, 2004 05:28 AM UTC

In fact I''m moving from MSDATAGRID and I''d like to be able to test against the same type than DataGrid.HitTestType. Especially RowResize and ColumnResize. >Here is code that gives you the row and col index of the hit. From there you would compare these values against grid.Cols.HeaderCount or grid.Rows.HeaderCount to decide whether the cell was a header or not. > > >//get the point somehow >//could possible use event args here >//but make sure the point is in the grid''s coordinates >Point pt = grid.PointToClient(Control.MousePosition); >if(grid.PointToRowCol(pt, out row, out col, -1)) >{ >// row and col now hold their values >} >


AD Administrator Syncfusion Team October 15, 2004 06:05 AM UTC

This forum is for support of our Essential Grid products.


LO Louis October 15, 2004 06:26 AM UTC

Sorry if I''m not clear. I''m effectively working with Essential Grid products. As I tried to explain I can''t see how to know on which part of the grid the mouse is. For example if the mouse is over a horizontal grid line between headers or if the mouse is over a vertical grid line between headers... Thank''s for your reply Louis


AD Administrator Syncfusion Team October 15, 2004 06:35 AM UTC

I am sorry. The above code can tell you when you are over particular cells. If you want to know when you are sizing a column or row, you can handle the ResizingColumns and ResizingRows events. The evernt args has much information about what is happen including a Reason property.


LO Louis October 15, 2004 07:07 AM UTC

That''s fine, Thank''s a lot Louis >I am sorry. > >The above code can tell you when you are over particular cells. > >If you want to know when you are sizing a column or row, you can handle the ResizingColumns and ResizingRows events. The evernt args has much information about what is happen including a Reason property.

Loader.
Live Chat Icon For mobile
Up arrow icon