Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

GetHitTypeByHitCode(Integer) Method

Converts the hit code to the grid element identifier.

#Declaration

Delphi
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