unit JvDbGridTitleClick;
interface
uses
SysUtils, Classes, Controls, Grids, DBGrids, JvExDBGrids, JvDBGrid;
type
TJvDbGridTitleClick =
class(TJvDBGrid)
private
{ Private declarations }
FOnTitleRightClick: TDBGridClickEvent;
protected
{ Protected declarations }
public
{ Public declarations }
procedure TitleRightClick(Column: TColumn);
dynamic;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
override;
published
{ Published declarations }
property OnTitleRightClick: TDBGridClickEvent
read FOnTitleRightClick
write FOnTitleRightClick;
end;
procedure Register;
implementation
procedure TJvDbGridTitleClick.MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
var
Cell: TGridCoord;
begin
inherited MouseUp(Button, Shift, X, Y);
Cell := MouseCoord(X,Y);
if (Button = mbright)
and (Cell.X >= IndicatorOffset)
and (Cell.Y = 0)
then
TitleRightClick(Columns[RawToDataColumn(Cell.X)]);
end;
procedure TJvDbGridTitleClick.TitleRightClick(Column: TColumn);
begin
if Assigned(FOnTitleRightClick)
then FOnTitleRightClick(Column);
end;
procedure Register;
begin
RegisterComponents('
Samples', [TJvDbGridTitleClick]);
end;
end.