function TDBGridEx.MouseCoord(X, Y: Integer): TGridCoord;
begin
Result := inherited MouseCoord(X, Y);
end;
function TDBGridEx.GetEditText(ACol, ARow: Longint): string;
begin
if (ACol > 0) and (ACol < ColCount) and (ARow > 0) and (ARow < RowCount)
then
Result := inherited GetEditText(ACol, ARow)
else
Result := '';
end;
procedure TDBGridEx.MouseMove(Shift: TShiftState; X, Y: Integer);
Var
C:TGridCoord;
OldActive:Integer;
Value:String;
begin
inherited MouseMove (Shift, X, Y);
C:=MouseCoord(X,Y);
if (OldGridCoord.X = C.X) and (OldGridCoord.Y = C.Y) then Exit;
OldGridCoord := C;
Value := '';
OldActive := DataLink.ActiveRecord;
Try
if C.Y > 0 then
DataLink.ActiveRecord := C.Y-1
else
DataLink.ActiveRecord := C.Y;
{Value := GetFieldValue(C.X);}
Value := GetEditText(C.X,C.Y);
Finally
DataLink.ActiveRecord := OldActive;
End;
if Application <> nil then
Application.CancelHint;
참고하시고 즐거운 프로그래밍 하시길~~
unit DBGridEx;
{ ==================================================== }
{ ==================================================== }
interface
{ ==================================================== }
uses DBGrids, Grids, Controls, Classes, Forms;
type
TDBGridEx = class( TDBGrid )
private
OldGridCoord : TGridCoord;
public
Application : TApplication;
function MouseCoord(X, Y: Integer): TGridCoord;
function GetEditText(ACol, ARow: Longint): string;override;
procedure MouseMove(Shift: TShiftState; X, Y: Integer);override;
published
property OnMouseMove;
property OnMouseDown;
property OnMouseUp;
end;
procedure Register;
{ ==================================================== }
implementation
{ ==================================================== }
function TDBGridEx.MouseCoord(X, Y: Integer): TGridCoord;
begin
Result := inherited MouseCoord(X, Y);
end;
function TDBGridEx.GetEditText(ACol, ARow: Longint): string;
begin
if (ACol > 0) and (ACol < ColCount) and (ARow > 0) and (ARow < RowCount)
then
Result := inherited GetEditText(ACol, ARow)
else
Result := '';
end;
procedure TDBGridEx.MouseMove(Shift: TShiftState; X, Y: Integer);
Var
C:TGridCoord;
OldActive:Integer;
Value:String;
begin
inherited MouseMove (Shift, X, Y);
C:=MouseCoord(X,Y);
if (OldGridCoord.X = C.X) and (OldGridCoord.Y = C.Y) then Exit;
OldGridCoord := C;
Value := '';
OldActive := DataLink.ActiveRecord;
Try
if C.Y > 0 then
DataLink.ActiveRecord := C.Y-1
else
DataLink.ActiveRecord := C.Y;
{Value := GetFieldValue(C.X);}
Value := GetEditText(C.X,C.Y);
Finally
DataLink.ActiveRecord := OldActive;
End;
if Application <> nil then
Application.CancelHint;
Hint:=Value;
end;
{ ==================================================== }
procedure Register;
begin
RegisterComponents('Data Controls',[TDBGridEx]);
end;
{ ==================================================== }
end.