I have a Windows form with a calendar which is hidden. I want to show the form right under the current cell of a DataGridView. The position changes according to the position
You may try
[DllImport("user32.dll", EntryPoint = "GetCursorPos")]
private static extern bool GetCursorPos(out Point lpPoint);
and call method as
Point pt;
GetCursorPos(out pt);
pt will provide x and y.
You may want to try this:
Lookup_Account.Left = datagrid_setting.GetCellDisplayRectangle(colIndex, rowIndex, False).Left
Lookup_Account.Top = datagrid_setting.GetCellDisplayRectangle(colIndex, rowIndex, False).Top
You can use paygrid.PointToScreen() method.
form_date.Location = paygrid.PointToScreen(
paygrid.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false).Location);
Rectangle cellRect = paygrid.GetCellDisplayRectangle(e.ColumnIndex,
e.RowIndex, true);
So You can use:
cellRect.X - for X position, cellRect.Y - for Y position,
cellRect.Width - for column width and cellRect.Height - for column height