GetHitTypeByHitCode(Integer) Method
Converts the hit code to the grid element identifier.
Declaration
function GetHitTypeByHitCode(AHitCode: Integer): TcxGridViewHitType;
Parameters
Name | Type |
---|---|
AHitCode | Integer |
Returns
Type |
---|
TcxGridViewHitType |
Remarks
Commonly, a grid element identifier is used to determine the grid View element that can display popup menus. Refer to the TcxPopupMenuInfo.HitTypes and TcxGridPopupMenu.HitType property descriptions to learn more.
The following example demonstrates how to use the GetHitTypeByHitCode function in a TcxPopupMenuInfo.OnPopup event handler to identify the grid View element for which the pop-up menu is invoked.
procedure TForm1.cxGridPopupMenu1PopupMenus0Popup(ASenderMenu: TComponent; AHitTest: TcxCustomGridHitTest; X, Y: Integer);
var
AHitType: TcxGridViewHitType;
begin
AHitType := GetHitTypeByHitCode(AHitTest.HitTestCode);
if AHitType = gvhtCell then
begin
if Odd((AHitTest as TcxGridRecordCellHitTest).GridRecord.Index) then
PopupMenu1.Popup(X, Y)
else
PopupMenu2.Popup(X, Y)
end;
end;
The code above assumes that you have an application with a TcxGridPopupMenu component named cxGridPopupMenu1 and two TPopupMenu components named PopupMenu1 and PopupMenu2 correspondingly.
See Also