|
sfDataGrid.TableControl.MouseUp += SfDataGrid_MouseUp;
//Get the record context while AddingNewRow menu by customization
private void SfDataGrid_MouseUp(object sender, MouseEventArgs e)
{
// get the row and column index based on the pointer position
var rowColIndex = sfDataGrid.TableControl.PointToCellRowColumnIndex(e.Location);
//Check the condition is AddNewRow and Only show the context menu while pressing right button of Mouse
if (e.Button == MouseButtons.Right && sfDataGrid.IsAddNewRowIndex(rowColIndex.RowIndex) && this.sfDataGrid.RecordContextMenu != null && !rowColIndex.IsEmpty)
{
ContextMenuStrip contextMenu = null;
//set the Record contextMenu for AddNewRow
contextMenu = this.sfDataGrid.RecordContextMenu;
//get the location
var location = this.sfDataGrid.TableControl.PointToScreen(e.Location);
if (contextMenu != null)
{
//show the ContextMenu for AddNewRow
contextMenu.Show(location);
}
}
} |