Delphi 10.1 Berlin을 사용하여 다중 장치 응용 프로그램을 만듭니다. 나는 쿼리의 일부 데이터를 나열하기 위해 TStringGrid
을 가지고있다.delphi TStringGrid 및 오른쪽 마우스 버튼
또한 팝업 메뉴 (편집, 삭제, ...)가 있지만 항목을 편집/삭제하려면 마우스 왼쪽 버튼을 사용하여 셀을 클릭해야합니다.
팝업 메뉴를 표시하기 전에 오른쪽 버튼을 사용하여 "행 선택"이 가능합니까?
procedure TForm1.StringGrid1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Button = mbRight then
StringGrid1.Perform(WM_LBUTTONDOWN, 0, MakeLParam(Word(X), Word(Y)));
end;
을하지만 mbRight
과 Perform()
에 오류를 표시합니다
procedure TForm39.StringGrid1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: single);
var
pf: TPointF;
begin
if Button = TMouseButton.mbRight then
begin
with Sender as TStringGrid do
SelectRow(RowByPoint(X, Y));
// Do not use the grids PopupMenu property, it seems it
// prevents this event handler comletely.
// Instead, activate the menu manually here.
pf := ClientToScreen(TPointF.Create(X, Y));
PopupMenu1.Popup(pf.X, pf.Y);
end;
end;
FireMonkey이 활성화 Scoped Enumerations 컴파일되므로 mbRight
버튼으로 문제가 열거 형 (TMouseButton.mbRight
)로 값을 접두사에 의해 해결된다 :
"멀티 장치 응용 프로그램"도 추가되었습니다. 항상 FMX 어플리케이션을위한'firemonkey' 태그를 추가하십시오. –
'OnMouseDown' 이벤트를 어떻게 추가 했습니까? FMX'TStringGrid'는 그러한 이벤트를 노출하지 않습니다. –
[편도] (https://pastebin.com/BbTG6pAB). – Victoria