How to select cell with right click in propertygrid
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.
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();
}
}
}
精彩评论