2013-07-11
展开全部
DBGrid一般用于DELPHI,在DELPHI中如下实现:
在OnMouseDown事件中实现以下代码:
procedure TForm1.DBGridEx1MouseDown(Sender: TObject; Button:
TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
iCol: Integer;
begin
with DBGridEx1 do
begin
iCol := MouseCoord(X, Y).X;
if (iCol > 0) and (iCol <= Columns.Count) then
Caption := Columns.Items[iCol - 1].FieldName;
end;
end;
在OnMouseDown事件中实现以下代码:
procedure TForm1.DBGridEx1MouseDown(Sender: TObject; Button:
TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
iCol: Integer;
begin
with DBGridEx1 do
begin
iCol := MouseCoord(X, Y).X;
if (iCol > 0) and (iCol <= Columns.Count) then
Caption := Columns.Items[iCol - 1].FieldName;
end;
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询