2011-07-13 39 views
5

如何在Delphi中通过制表符或箭头键在字符串网格的单元格之间移动?如你所知,delphi中的一个字符串网格只有一个tab键顺序,但我需要通过箭头键或tab键在单元格之间移动,以便更加舒适和用户友好。delphi:在字符串网格的单元格之间移动

我试图用一个按键事件,但这个事件只知道个字符,不知道像标签控制键和...

+0

关于错误:http://meta.stackexchange.com/questions/92074/what-c​​an-i-do-when-getting-it-does-not-meet-our-quality-standards –

回答

5
StringGrid.Options := StringGrid.Options + [goEditing, goTabs]; 

或者设置这个设计时。

现在,您可以使用制表符和箭头键从单元格移动到单元格。如果您实际上正在编辑一个单元格,那么如果要移动到单元格的左侧或右侧,则必须先释放焦点。在这种情况下,使用(shift)选项卡。

+0

为什么goEditing? –

+0

哦,我的上帝,,,,它是我生命中最好的答案。谢谢 。 – Arash

+0

goediting是用于单元格的类型,,,如果其错误不能在单元格中输入 – Arash

0
{ This handles arrow left and right in the GRID 
} 
procedure TJournalForm.JournalGridKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); 

begin 
    if (JournalGrid.EditorMode = True) then  // if arrowing while editing… 
     begin 
      if Key=VK_Left then if JournalGrid.Col>(JournalGrid.FixedCols+1) then JournalGrid.Col:=JournalGrid.Col-1; 
     if Key=VK_Right then if JournalGrid.Col<(JournalGrid.ColCount-1) then JournalGrid.Col:=JournalGrid.Col+1; 
    end; 
end; 
+1

在为Col属性设置新值之前设置EditorMode:= false。 –