cxGrid 6 FocusedRecordChanged 想知道 FocusedItemChanged 是否

发布于 2024-09-30 02:29:39 字数 359 浏览 0 评论 0原文

我将 GotToNextCellOnEnter 和 FocuscellOnCycle 属性设置为 true。当我在最后一个单元格上按 Enter 时,将触发 FocusedRecordChanged 事件,然后触发 FocusedItemChanged 事件。有没有办法检测 FocusedItemChanged 事件是由于 FocusRecordChanged 事件内部触发而导致的。我试图使用这些事件阻止用户关注特定的单元格。如果 FocusedItemChanged 事件将在 FocusedRecordChanged 事件之后触发,我想忽略 FocusedRecordChanged 事件。理想情况下,我想要的是 FocusedCellChanged 事件,但没有其中之一。

谢谢

I have the GotToNextCellOnEnter and the FocuscellOnCycle properties set to true. When I press enter on the last cell the FocusedRecordChanged event fires and then the FocusedItemChanged event fires. Is there a way of detecting that the FocusedItemChanged event is due to fire from within the FocusRecordChanged event. I am trying to use these events stop the user from focusing on specific cells. I want to ignore the FocusedRecordChanged event if the FocusedItemChanged event is going to fire just after it. Ideally what I want is a FocusedCellChanged event but there is not one of these.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

全部不再 2024-10-07 02:29:39

正如 ExpressQuantumGrid Suite 6 的帮助中所述,OnFocusedRecordChanged

焦点移至不同记录后发生。

和 OnFocusedItemChanged

当焦点更改到不同的视图项时发生。

其中 Item 是一列。

这意味着(在您当前的配置下,即 GoToNextCellOnEnter 和 FocusCellOnCycle 设置为 true)每次您按 Enter 键离开记录的最后一列时,这两个事件始终都会触发因为您要移至下一条记录的第一项。

编辑:在使用向下键离开的情况下,OnFocusedItem 不会触发是绝对正常的,因为只有在更改列时它才会触发。你可以尝试夺取离开牢房的钥匙。我的猜测是 OnKeyDown 事件发生在这两个事件之前。

如果我正确理解您的需求,您将需要在事件处理程序中以不同的方式处理最后一列。

希望有帮助,

最好的问候

As stated in the help for the ExpressQuantumGrid Suite 6 the OnFocusedRecordChanged

Occurs after focus is moved to a different record.

and the OnFocusedItemChanged

Occurs when focus is changed to a different View item.

where an Item is a column.

That means that (with your current configuration, i.e., GoToNextCellOnEnter and FocusCellOnCycle set to true) everytime you leave pressing the Enter key the last column of a record both events will always fire since you are moving to the first item of the next record.

EDIT: In the case of leaving with the Down key it is absolutely normal that the OnFocusedItem does not fire since it only does so if you change the column. You could try to capture the key used to leave the cell. My guess is that the OnKeyDown event occurs before any of these 2 events.

If I understood your needs right, you will need to treat the last column differently in your event handlers.

Hope that helps,

Best regards

紧拥背影 2024-10-07 02:29:39

我建议您禁用这两个选项并自己实现此逻辑。这是默认实现,您只需更改它即可满足您的自定义逻辑:

procedure TForm1.cxGrid1DBTableView1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var
  ASite: TcxGridSite;
begin
  if Key = VK_RETURN then
  begin
    ASite := TcxGridSite(Sender);
    FocusNextCell(TcxGridTableView(ASite.GridView));
    Key := 0;
  end;
end;

procedure TForm1.cxGrid1DBTableView1EditKeyDown(
  Sender: TcxCustomGridTableView; AItem: TcxCustomGridTableItem;
  AEdit: TcxCustomEdit; var Key: Word; Shift: TShiftState);
begin
  if Key = VK_RETURN then
  begin
    FocusNextCell(TcxGridTableView(Sender));
    Key := 0;
  end;
end;

procedure TForm1.FocusNextCell(AView: TcxGridTableView);
var
  AColumn: TcxGridColumn;
begin
  AColumn := AView.Controller.FocusedColumn;
  if AView.Controller.FocusedRow.IsData then
  begin
    if AColumn.VisibleIndex < AView.VisibleColumnCount - 1 then
      AView.VisibleColumns[AColumn.VisibleIndex + 1].Focused := True
    else
      if AView.Controller.FocusNextRecord(AView.Controller.FocusedRecordIndex, True, True, False, False) and AView.Controller.FocusedRecord.HasCells then
        AView.VisibleColumns[0].Focused := True;
  end
  else
    if AView.Controller.FocusNextRecord(AView.Controller.FocusedRecordIndex, True, True, False, False) and AView.Controller.FocusedRecord.HasCells then
      AView.VisibleColumns[0].Focused := True;
  AView.Controller.EditingController.ShowEdit();
end;

I would suggest that you disable both options and implement this logic yourself. Here is the default implementation, you should just change it so that it meet your custom logic:

procedure TForm1.cxGrid1DBTableView1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var
  ASite: TcxGridSite;
begin
  if Key = VK_RETURN then
  begin
    ASite := TcxGridSite(Sender);
    FocusNextCell(TcxGridTableView(ASite.GridView));
    Key := 0;
  end;
end;

procedure TForm1.cxGrid1DBTableView1EditKeyDown(
  Sender: TcxCustomGridTableView; AItem: TcxCustomGridTableItem;
  AEdit: TcxCustomEdit; var Key: Word; Shift: TShiftState);
begin
  if Key = VK_RETURN then
  begin
    FocusNextCell(TcxGridTableView(Sender));
    Key := 0;
  end;
end;

procedure TForm1.FocusNextCell(AView: TcxGridTableView);
var
  AColumn: TcxGridColumn;
begin
  AColumn := AView.Controller.FocusedColumn;
  if AView.Controller.FocusedRow.IsData then
  begin
    if AColumn.VisibleIndex < AView.VisibleColumnCount - 1 then
      AView.VisibleColumns[AColumn.VisibleIndex + 1].Focused := True
    else
      if AView.Controller.FocusNextRecord(AView.Controller.FocusedRecordIndex, True, True, False, False) and AView.Controller.FocusedRecord.HasCells then
        AView.VisibleColumns[0].Focused := True;
  end
  else
    if AView.Controller.FocusNextRecord(AView.Controller.FocusedRecordIndex, True, True, False, False) and AView.Controller.FocusedRecord.HasCells then
      AView.VisibleColumns[0].Focused := True;
  AView.Controller.EditingController.ShowEdit();
end;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文