Reputation: 2930
I have a propertyGridControl - how to handle when mouse right is clicked on it - if its clicked on a row but only on the value of the property in this row and not on the cell in which is the name of the property? Now its just raising the rightclick event and not marking the cell.
Upvotes: 0
Views: 2101
Reputation: 11376
Such tasks are usually implemented using the control's CalcHitInfo method. It is used to determine the clicked control's area. Here is the code:
private void propertyGridControl1_MouseClick(object sender, MouseEventArgs e) {
if(e.Button == System.Windows.Forms.MouseButtons.Right) {
VGridHitInfo hInfo = propertyGridControl1.CalcHitInfo(new Point(e.X, e.Y));
if(hInfo.HitInfoType == HitInfoTypeEnum.ValueCell) {
propertyGridControl1.FocusedRow = hInfo.Row;
propertyGridControl1.FocusedRecordCellIndex = hInfo.CellIndex;
propertyGridControl1.FocusedRecord = hInfo.RecordIndex;
propertyGridControl1.ShowEditor();
}
}
}
Upvotes: 1