如果我將DragMode設置爲dmAutomatic,它會阻止我選擇行。 如果我使用OnCellClick來調用BeginDrag,它只會在鼠標點亮時觸發,這在我看來並沒有拖動。 如果我使用OnMouseDown,它只會觸發標題行。如何從TDBGrid拖放?
我該怎麼做呢?
如果我將DragMode設置爲dmAutomatic,它會阻止我選擇行。 如果我使用OnCellClick來調用BeginDrag,它只會在鼠標點亮時觸發,這在我看來並沒有拖動。 如果我使用OnMouseDown,它只會觸發標題行。如何從TDBGrid拖放?
我該怎麼做呢?
重載MouseDown將導致期望的結果。
type
TDBGrid=Class(DBGrids.TDBGrid)
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
End;
TForm2 = class(TForm)
.......
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
{ TDBGrid }
procedure TDBGrid.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Begindrag(false);
inherited;
end;
我想你可能會發現下面的文章有用:http://delphi.about.com/library/weekly/aa042605a.htm – Peter
不是真的,因爲它使用的CellClick事件僅觸發鼠標了。在我看來,拖動是通過鼠標完成的(不是)。 – srayner