Пример #1
0
        public void RestoreSelection(
            [NotNull] BoundDataGridSelectionState <ROW> selectionState)
        {
            Assert.ArgumentNotNull(selectionState, nameof(selectionState));

            if (_msg.IsVerboseDebugEnabled)
            {
                _msg.VerboseDebugFormat("Restoring selection ({0} row(s))",
                                        selectionState.SelectionCount);
            }

            DataGridViewUtils.RestoreSelection(_dataGridView, selectionState);
        }
Пример #2
0
        public bool TrySortBindingList <T>([NotNull] IBindingList bindingList,
                                           [NotNull] DataGridView dataGridView)
            where T : class
        {
            var listSortDirection = GetListSortDirection();

            if (listSortDirection == null || SortedColumnName == null)
            {
                return(false);
            }

            return(DataGridViewUtils.TrySortBindingList <T>(
                       bindingList, dataGridView, SortedColumnName, listSortDirection.Value));
        }
Пример #3
0
        /// <summary>
        /// Binds a data grid view to the given binding list of rows
        /// </summary>
        /// <param name="rows">The rows.</param>
        /// <param name="autoGenerateColumns">Indicates if columns should be dynamically added based on the bound type</param>
        /// <param name="sortStateOverride">Optional sort state to apply regardless of the current sort state of the grid.</param>
        /// <param name="defaultSortState">Optional default sort state, to be applied when there is no current or override sort state.</param>
        /// <param name="selectionStateOverride"></param>
        public bool BindTo([NotNull] IList <ROW> rows,
                           bool autoGenerateColumns = false,
                           DataGridViewSortState sortStateOverride = null,
                           DataGridViewSortState defaultSortState  = null,
                           BoundDataGridSelectionState <ROW> selectionStateOverride = null)
        {
            Assert.ArgumentNotNull(rows, nameof(rows));

            return(DataGridViewUtils.BindTo(_dataGridView, rows,
                                            autoGenerateColumns,
                                            sortStateOverride,
                                            defaultSortState,
                                            selectionStateOverride));
        }
Пример #4
0
        public bool TryApplyState([NotNull] DataGridView dataGridView)
        {
            Assert.ArgumentNotNull(dataGridView, nameof(dataGridView));

            return(DataGridViewUtils.TryApplySortState(dataGridView, this));
        }
Пример #5
0
 public BoundDataGridSelectionState <ROW> GetSelectionState()
 {
     return(DataGridViewUtils.GetSelectionState <ROW>(_dataGridView));
 }
Пример #6
0
        // This overload would be useful, but the scrolling to the first selected
        // row does not work. Further analysis needed. Possibly the FirstDisplayedScrollingRowIndex
        // call must be in a later event?

        //public void RestoreSelection(BoundDataGridSelectionState<ROW> selectionState,
        //                     bool ensureFirstSelectedRowIsVisible)
        //{
        //    Assert.ArgumentNotNull(selectionState, "selectedRows");

        //    if (selectionState.SelectionCount == 0)
        //    {
        //        return;
        //    }

        //    DataGridViewRow firstSelectedRow = null;

        //    foreach (DataGridViewRow row in _dataGridView.Rows)
        //    {
        //        ROW tableRow = row.DataBoundItem as ROW;

        //        if (tableRow != null && selectionState.IsSelected(tableRow))
        //        {
        //            if (firstSelectedRow == null)
        //            {
        //                firstSelectedRow = row;
        //            }

        //            row.Selected = true;
        //        }
        //    }

        //    if (ensureFirstSelectedRowIsVisible && firstSelectedRow != null)
        //    {
        //        if (!firstSelectedRow.Displayed)
        //        {
        //            _dataGridView.CurrentCell = firstSelectedRow.Cells[0];
        //            _dataGridView.FirstDisplayedScrollingRowIndex = firstSelectedRow.Index;
        //        }
        //    }
        //}

        public bool IsSortingColumn([NotNull] DataGridViewCellMouseEventArgs e)
        {
            return(DataGridViewUtils.IsColumnSortEvent(_dataGridView, e));
        }