DBGrid - saber em que coluna foi clicado quando o rowselect esta true |
Top Previous Next |
|
// saber em que coluna foi clicado quando o rowselect esta true
function OnColumn(const Grd: TDBGrid; const Campo: TField): Boolean; var Pt : TPoint; W, I: Integer; begin GetCursorPos(Pt); Windows.ScreenToClient(GetParentForm(Grd).Handle, Pt); // Converte para a posicao relativa ao form W := Grd.Left; for I := 0 to Grd.Columns.Count-1 do if Grd.Columns[I].Field = Campo then Break else W := W + Grd.Columns[I].Width; Result := (Pt.X >= W) and (Pt.X <= W + Grd.Columns[I].Width); end;
procedure TMainForm.GridCellClick(Column: TColumn); begin if OnColumn(Grid, TbMarca) then GridDblClick(Grid); end; |