title: How do you Remove the Black Line from a Delphi DBGrid OnTitleClick Event?
body: <p>I have a Delphi DBGrid that looks normal when it first loads. I have setup an <strong>OnTitleClick</strong> 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)</p>
  
  <p>As soon as the click event is done, the grid looks normal again.</p>
  
  <p>How do you prevent this black line from appearing when you click the column title?</p>
  
  <p><img src="https://i.stack.imgur.com/gklcd.jpg" alt="enter image description here"></p>
  
  <h3>EDIT: QC Submitted to Embarcadero</h3>
  
  <p>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 <a href="http://qc.embarcadero.com/wc/qcmain.aspx?d=98255" rel="nofollow noreferrer">QC 98255</a> to Embarcadero. Please vote for this entry.</p>
  
  <h3>UPDATE: 2017-07-30</h3>
  
  <p>I found where this horizontal black line is being drawn.<br>
  <strong>Vcl.Grids</strong> > <strong>procedure</strong> TCustomGrid.DrawMove;  </p>
  
  <p>The Canvas.Pen.Width is set to 5. I changed it so the Canvas.Pen.Width := 1;<br>
  It looks much so much better. Now when I clicked on the <em>"Contact_Last"</em> title cell the black indicator line is just one pixel wide and much less intrusive. </p>
  
  <p><a href="https://i.stack.imgur.com/cXF8o.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cXF8o.png" alt="enter image description here"></a></p>
  
  <pre><code>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 &gt; FMoveIndex then
              Pos := R.Bottom else
              Pos := R.Top;
            MoveTo(0, Pos);
            LineTo(ClientWidth, Pos);
          end
          else
          begin
            R := CellRect(FMovePos, 0);
            if FMovePos &gt; 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;
  </code></pre>