본문 바로가기

Delphi/간단하게

cxGrid에서 선택한 Cell의 컬럼정보 가져오기

1. OnCellClick 이벤트에서 가져오기

procedure TForm1.<cxGridTableView>CellClick(Sender: TcxCustomGridTableView; ACellFViewinfo: TcxGridTableDataCellViewInfo;
  AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
begin
  //ACellViewInfo.Item = Column
  ShowMessage(ACellViewInfo.Item.Caption);
end;

2. OnMouseDown 이벤트에서 가져오기

procedure TForm1.<cxGridTableView>MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  SenderHitTest: TcxGridRecordCellHitTest;
begin
  SenderHitTest := TcxGridTableView(TcxGridSite(Sender).GridView).ViewInfo.GetHitTest(Point(X, Y)) as TcxGridRecordCellHitTest;
  
  if SenderHitTest <> nil then
    //SenderHitTest.Item = Column
    ShowMessage(SenderHitTest.Item.Caption);
end;
반응형