开发者

How do you Remove the Black Line from a Delphi DBGrid OnTitleClick Event?

I have a Delphi DBGrid that looks normal when it first loads. I have setup an OnTitleClick event that sorts the DBGrid by the column when the title is clicked. As soon as you click on the title, the column title acts like a button being pressed and an ugly black line appears. (See Fig. 2 below)

As soon as the click event is done, the grid looks normal again.

How do you prevent this black line from appearing when you click the column title?

How do you Remove the Black Line from a Delphi DBGrid OnTitleClick Event?

EDIT: QC Submitted to Embarcadero

While turning off the ability to resize columns does make the black line behavior disappear it does take away a very nice feature. I think this behavior needs to be fixed. I have submitted the following QC 98255 to Embarcadero. Please vote for this entry.

UPDATE: 2017-07-30

I found where this horizontal black line is being drawn.

Vcl.Grids > procedure TCustomGrid.DrawMove;

The Canvas.Pen.Width is set to 5. I changed it so the Canvas.Pen.Width := 1;

It looks much so much better. Now when I clicked on the "Contact_Last" title cell the black indicator line is just one pixel wide and much less intrusive.

How do you Remove the Black Line from a Delphi DBGrid OnTitleClick Event?

procedure TCustomGrid.DrawMove;
var
  OldPen: TPen;
  Pos: Integer;
  R: TRect;
begin
  OldPen := TPen.Create;
  try
    with Canvas do
    begin
      OldPen.Assign(Pen);
      try
        Pen.Style := psDot;
        Pen.Mode := pmXor;
        //+----------------------------------------------------------------+
        // Modified 2017-07-30 by Michael J Riley (MJR)
        // Changed Pen.Width from 5 to 1
        // This makes the vertical black move-indicator line 1 pixel wide
        // Which is the same width as column resize vertical line
        //+----------------------------------------------------------------+
        //Pen.Width := 5;
        Pen.Width := 1;
        if FGridState = gsRowMoving then
        begin
          R := CellRect(0, FMovePos);
          if FMovePos > FMoveIndex then
            Pos := R.Bottom else
            Pos := R.Top;
          MoveTo(0, Pos);
          LineTo(ClientWidth, Pos);
        end
        else
     开发者_如何学Go   begin
          R := CellRect(FMovePos, 0);
          if FMovePos > FMoveIndex then
            if not UseRightToLeftAlignment then
              Pos := R.Right
            else
              Pos := R.Left
          else
            if not UseRightToLeftAlignment then
              Pos := R.Left
            else
              Pos := R.Right;
          MoveTo(Pos, 0);
          LineTo(Pos, ClientHeight);
        end;
      finally
        Canvas.Pen := OldPen;
      end;
    end;
  finally
    OldPen.Free;
  end;
end;


The black line looks like a column order insert marker.

Try looking for an option that disables column re-ordering.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜