简体   繁体   English

如何在 DevExpress Grid 中使用空字符串而不是 null 分配字符串项

[英]How to assign string item with empty string instead of null in DevExpress Grid

I need to set the string item value to "empty string" and not to null by pressing DEL when editing a devexpress grid.我需要在编辑 devexpress 网格时按 DEL 将字符串项值设置为“空字符串”而不是 null。

On the event getDisplayText of your column you can add在您的列的事件 getDisplayText 上,您可以添加

Procedure <youtview>.YourColumnGetDisplayText(Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AText: string);
begin
 if AText = '' then
   AText := 'empty string';
end;

It's been a couple of years since I've seen Delphi, but there are events triggered on each item within a devexpress grid.自从我看到 Delphi 以来已经有几年了,但是在 devexpress 网格中的每个项目上都会触发事件。 Identify the 'OnKeyUp' event or similar, and add a method to identify the key pressed.识别“OnKeyUp”事件或类似事件,并添加一个方法来识别按下的键。 If it is the DEL key, set the text value to ''.如果是 DEL 键,则将文本值设置为 ''。

The Delete key is VK_DELETE.删除键是 VK_DELETE。 Here is a list of other virtual keys for Delphi as well: http://delphi.about.com/od/objectpascalide/l/blvkc.htm以下是 Delphi 的其他虚拟键列表: http://delphi.about.com/od/objectpascalide/l/blvkc.htm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM