我在 TTab 中有许多 TStringGrid,并且多年来一直使用
if (Key==VK_RETURN) 作为触发器来执行与单元格条目相关的代码。
我现在希望通过向其中写入一个空字符串来删除单元格内容的选项,因此尝试使用 if (Key==VK_DELETE)
但在我的情况下,删除按钮根本不会触发 OnKeyPress 事件。
我希望通过以下与特定活动 Stringrid1 相关的代码来捕获事件
void __fastcall TPagesDlgLoadEditorFixed::StringGrid1KeyPress(TObject
*Sender, char &Key)
{
int Grid = 1;
EntriesOnStringGrid(Key, Grid);
}
然后使用 KeyPress 传递所有 StringGrids 共有的代码,如下所示:
void TPagesDlgLoadEditorFixed::EntriesOnStringGrid(char &Key, int Grid)
{
if (Key==VK_RETURN)
{
//code works fine
}
if (Key==VK_DELETE)
{
//code has no effect
}
}
然而,在调试模式下,可以看到“删除”按钮根本没有触发 StringGrid1KeyPress 事件。
任何建议将不胜感激。