[SOLVED] DGV Cell Location

Answered Closed


Recently I was looking for the Location of a clicked DGV-Cell on the display.
The object cell seems to have a Size property, but obviously no Location.

With WindowsForms you can find the Location if you extract it e.g. with

Rectangle rec = DisplayedDGV.GetCellDisplayRectangle(1, e.RowIndex, true);
Point cellLocation = new Point(rec.Location);

Unfortunately, the Wisej DGVCell seems neither to have a Method similar to GetCellDisplayRectangle(), nor the DisplayRectangle property like the DGV itself.

Could you please suggest a way to find out the location of a clicked cell? [(Left;Top) or (X;Y)]

Thanks a lot,

  • You must to post comments
Best Answer


with WJ-7689  Add GetCell-/Row/ColumnDisplayRectangle have been added
in the latest Wisej release (1.3.35).

Best regards

  • You must to post comments

Hi, many thanks for your proposal.

Actually I was only trying to create a temporary replacement for a Master-Detail (hierarchical) DataGridView.
Though the native Windows Forms control datagridview also doesn’t support Master-Detail views within a single control, CodeProject or c-sharpcorner are offering some not too difficoult samples for it.
As a first try I took a project of Sayed Shanu http://www.c-sharpcorner.com/uploadfile/asmabegam/master-detail-datagridview-in-c-sharp-winform/.

The conversion is quite simple, for the positioning of the detailDGV I took the iteration way as you proposed (even if it’s not exactly an elegant solution).
My only problem is the image column on the left. The images get visible only after the first mouse click.
What’s wrong with them?

Thanks, Andreas

  • You must to post comments

Hi Andreas,

At the moment we didn’t implement the GetCell/Row/ColumnDisplayRectangle methods. In WinForms they are mostly  used to draw the cells and in Wisej the UI is entirely managed by the themes and the javascript widgets.

It’s relatively easy to add those methods, the only issue is the scroll position. I will log an enhancement for these methods.

As a quick workaround you can iterate the columns and rows and get the location by adding the column.Width and row.Height. WinForms does the same internally. What do you need the cell rect for? If it’s used mostly in clicks, it’s faster to make the widget return the rect with the click event and avoid the iteration.



  • You must to post comments
Showing 3 results