Source/NFX.WinForms/Controls/GridKit/Grid.cs
/// <summary>
/// Dispatches appropriate events and performs row selection in the grid
/// </summary>
Dispatches appropriate events and performs row selection in the grid
Dispatches appropriate events and performs row selection in the grid
public virtual void DispatchCellSelection(CellElement cell)
      {
        if (cell.Row!=null)
        {
          if (!m_MultiSelect)
          {
            if ((Control.ModifierKeys & Keys.Control) > 0)
              UnSelectRow(cell.Row);
            else
              SelectRow(cell.Row);
          }
          else 
          {
            if ((Control.ModifierKeys & Keys.Shift) > 0)
            {
              if (!SelectedRows.Any())
              {
                SelectRow(cell.Row);
                return;
              }
              var first = m_RowMap.FindIndex(re => re.Row == SelectedRows.First());
              var last  = m_RowMap.FindIndex(re => re.Row == SelectedRows.Last());
              var cur   = m_RowMap.FindIndex(re => re.Row == cell.Row);
              if (cur < 0)
                return;
              UnSelectAllRows();
              if (last <= cur)
                for (var i = last; i <= cur; ++i)
                  SelectRow(m_RowMap[i].Row);
              else if (cur <= first)
                for (var i = cur; i <= first; ++i)
                  SelectRow(m_RowMap[i].Row);
            }
            else if (!m_MultiSelectWithCtrl || (Control.ModifierKeys & Keys.Control) > 0)
            {
              if (IsRowSelected(cell.Row))
                UnSelectRow(cell.Row);
              else
                SelectRow(cell.Row);
            }
            else
            {
              UnSelectAllRows();
              SelectRow(cell.Row);
            }
          }
        }
        if (m_CellSelectionAllowed)
          try
          {
            rebuildAllCells(true);
            OnCellSelection(m_SelectedCell, cell);
          }finally{
            m_SelectedCell = cell;
          } 
      }
public virtual void DispatchCellSelection ( CellElement cell ) { if ( cell . Row != null ) { if ( ! m_MultiSelect ) { if ( ( Control . ModifierKeys & Keys . Control ) > 0 ) UnSelectRow ( cell . Row ) ; else SelectRow ( cell . Row ) ; } else { if ( ( Control . ModifierKeys & Keys . Shift ) > 0 ) { if ( ! SelectedRows . Any ( ) ) { SelectRow ( cell . Row ) ; return ; } var first = m_RowMap . FindIndex ( re => re . Row == SelectedRows . First ( ) ) ; var last = m_RowMap . FindIndex ( re => re . Row == SelectedRows . Last ( ) ) ; var cur = m_RowMap . FindIndex ( re => re . Row == cell . Row ) ; if ( cur < 0 ) return ; UnSelectAllRows ( ) ; if ( last <= cur ) for ( var i = last ; i <= cur ; ++ i ) SelectRow ( m_RowMap [ i ] . Row ) ; else if ( cur <= first ) for ( var i = cur ; i <= first ; ++ i ) SelectRow ( m_RowMap [ i ] . Row ) ; } else if ( ! m_MultiSelectWithCtrl || ( Control . ModifierKeys & Keys . Control ) > 0 ) { if ( IsRowSelected ( cell . Row ) ) UnSelectRow ( cell . Row ) ; else SelectRow ( cell . Row ) ; } else { UnSelectAllRows ( ) ; SelectRow ( cell . Row ) ; } } } if ( m_CellSelectionAllowed ) try { rebuildAllCells ( true ) ; OnCellSelection ( m_SelectedCell , cell ) ; } finally { m_SelectedCell = cell ; } }
Dispatches appropriate events and performs row selection in the grid
Dispatches appropriate events and performs row selection in the grid
//multiselect //must force the rebuild or event will be invalid
cell
CellElement