带有通配符的Delphi dbgrid

0 delphi

我有DBGrid.有时候,如果我改变一些单元格值,它会给出一个通配符.你可以在图像中看到.

IMG

我的问题:当这个通配符出现时,它可以出现吗?如何禁用它?

Joh*_*ica 6

*是dbgrid处于插入模式的指示符.

如果您不希望显示此指示符,则可以在OnDrawColumnCell事件中更改(绘制)它.
如果您使用此事件,则可能需要设置dbGrid.DefaultDrawing为false.

另见:http://docwiki.embarcadero.com/RADStudio/Seattle/en/Controlling_Grid_Drawing

另一种选择是实现自己的自定义样式.

type
  TMyStyleWithNoIndicator = class(TCustomStyleServices)
    function GetElementDetails(Detail: TThemedGrid): TThemedElementDetails; override;  
  end;

  function TMyStyleWithNoIndicator.GetElementDetails(Detail: TThemedGrid): TThemedElementDetails; 
  begin
    inherited;
    //prevent drawing of the insert indicator.
    if Detail in [tgIndicatorInsert] then Result.State = Ord(tgCellNormal);
  end;

  procedure TForm1.Form1Create(Sender: TObject);
  begin
    TStyleManager.SetStyle(TMyStyleWithNoIndicator.Create);
  end;
Run Code Online (Sandbox Code Playgroud)