[英]How do you Remove the Black Line from a Delphi DBGrid OnTitleClick Event?
我有一個Delphi DBGrid,它在第一次加載時看起來很正常。 我已經設置了一個OnTitleClick事件,在單擊標題時按列對DBGrid進行排序。 單擊標題后,列標題就像按下按鈕一樣,出現一條丑陋的黑線。 (見下圖2)
單擊事件完成后,網格再次顯示正常。
單擊列標題時如何防止出現黑線?
雖然關閉調整列大小的功能確實會使黑線行為消失,但它確實會帶走一個非常好的功能。 我認為這種行為需要修復。 我已將以下QC 98255提交給Embarcadero。 請投票支持此條目。
我發現了這條水平黑線的繪制位置。
Vcl.Grids > 程序 TCustomGrid.DrawMove;
Canvas.Pen.Width設置為5.我更改了Canvas.Pen.Width:= 1;
它看起來好多了。 現在,當我點擊“Contact_Last”標題單元格時,黑色指示線只有一個像素寬,而且侵入性更小。
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
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;
黑線看起來像列順序插入標記。
嘗試尋找禁用列重新排序的選項。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.