1

如何获取 WPF 数据网格中仅可见列的计数。我正在使用计数来浏览数据网格中存在的列。

 if (getSelectedRow().IsEditing)
                    {
                        if (dataGrid.SelectedCells.Count != 0)
                        {
                            int columnDisplayIndex = dataGrid.CurrentCell.Column.DisplayIndex + 1;

                            if (columnDisplayIndex <= dataGrid.Columns.Count)
                            {
                                if (columnDisplayIndex == dataGrid.Columns.Count)

                                {
                                    row.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));

                                    nextColumn = dataGrid.ColumnFromDisplayIndex(nextCol(1) - 1);
                                    dataGrid.CurrentCell = new DataGridCellInfo(dataGrid.SelectedItem, nextColumn);

                                }
                                else
                                {
                                    e.Handled = true;
                                    nextColumn = dataGrid.ColumnFromDisplayIndex(nextCol(columnDisplayIndex));
                                    dataGrid.CurrentCell = new DataGridCellInfo(dataGrid.SelectedItem, nextColumn);
                                }

                            }
                        }

                        if (isNotComboBox())
                        {
                            dataGrid.CommitEdit();
                        }

                    }
4

0 回答 0