Esempio n. 1
0
        /// <summary>
        /// To find the first/last error cell in view if selection is not maintained in datagrid.
        /// </summary>
        private void MoveToErrorCell(SfDataGrid datagrid, bool MoveToFirstCell, ref bool moveToRow)
        {
            RowColumnIndex rowColumnIndex;

            if (MoveToFirstCell)
            {
                rowColumnIndex = new RowColumnIndex(datagrid.GetFirstDataRowIndex(), datagrid.GetFirstColumnIndex());
            }
            else
            {
                rowColumnIndex = new RowColumnIndex(datagrid.GetLastDataRowIndex(), datagrid.GetLastColumnIndex());
            }

            datagrid.SelectionController.MoveCurrentCell(rowColumnIndex);
            var currentRowColumnIndex = datagrid.SelectionController.CurrentCellManager.CurrentRowColumnIndex;
            var gridCellCollections   = GetGridCellCollection(datagrid, currentRowColumnIndex);

            if (gridCellCollections != null)
            {
                foreach (var gridCellItem in gridCellCollections)
                {
                    var gridCell = gridCellItem as GridCell;
                    if (gridCell != null && gridCell.HasError && gridCell.ColumnBase.ColumnIndex == currentRowColumnIndex.ColumnIndex)
                    {
                        datagrid.SelectionController.MoveCurrentCell(new RowColumnIndex(currentRowColumnIndex.RowIndex, gridCell.ColumnBase.ColumnIndex));
                        datagrid.ScrollInView(datagrid.SelectionController.CurrentCellManager.CurrentRowColumnIndex);;
                        moveToRow = false;
                        return;
                    }
                }
            }
        }
        /// <summary>
        /// Get the index value for the next focused GridColumn.
        /// </summary>
        /// <param name="DataGrid"></param>
        /// <param name="columnIndex"></param>
        /// <returns></returns>
        internal static int GetNextFocusGridColumnIndex(this SfDataGrid DataGrid, int columnIndex, FlowDirection flowdirection = FlowDirection.LeftToRight)
        {
            if (flowdirection == FlowDirection.RightToLeft)
            {
                return(GetPreviousFocusGridColumnIndex(DataGrid, columnIndex));
            }
            var index = columnIndex;

            if (index < 0 || index >= DataGrid.Columns.Count)
            {
                return(-1);
            }
            var gridColumn = DataGrid.Columns[index];

            if (gridColumn == null || !gridColumn.AllowFocus || gridColumn.ActualWidth == 0.0 || gridColumn.IsHidden)
            {
                if (columnIndex + 1 < DataGrid.GetLastColumnIndex())
                {
                    index = GetNextFocusGridColumnIndex(DataGrid, columnIndex + 1);
                }
            }
            return(index);
        }