Esempio n. 1
0
 protected override void OnCellMouseEnter(DataGridViewCellEventArgs e)
 {
     if (m_isMouseDragSelecting && e != null && e.RowIndex >= 0 && e.RowIndex < Rows.Count)
     {
         // Drag-select a range of grid rows
         m_lastDragSelectedRowIndex = e.RowIndex;
         m_lowestDragSelectedIndex  = Math.Min(m_lowestDragSelectedIndex, e.RowIndex);
         m_highestDragSelectedIndex = Math.Max(m_highestDragSelectedIndex, e.RowIndex);
         SetCurrentRow(e.RowIndex);
         if (m_lowestDragSelectedIndex < LowerDragSelectedRowIndex)
         {
             SetRowSelection(m_lowestDragSelectedIndex, LowerDragSelectedRowIndex, false);
         }
         if (m_highestDragSelectedIndex > HigherDragSelectedRowIndex)
         {
             SetRowSelection(HigherDragSelectedRowIndex + 1, m_highestDragSelectedIndex + 1, false);
         }
         SetRowSelection(LowerDragSelectedRowIndex, HigherDragSelectedRowIndex + 1, true);
         this.Refresh();
         m_mainSplitContainer.SelectedResultsChanged();
     }
     base.OnCellMouseEnter(e);
 }
Esempio n. 2
0
        public void SetRowSelection(bool isControlA)
        {
            if (isControlA)
            {
                SetRowSelection(0, Rows.Count, true);
            }
            else
            {
                if (m_currentRowIndex != -1)
                {
                    if (m_isShiftDown)
                    {
                        if (m_firstSelectedRowIndex == -1 || m_firstSelectedRowIndex >= Rows.Count)
                        {
                            m_firstSelectedRowIndex = m_currentRowIndex;
                        }

                        int selectionBegin = Math.Min(m_firstSelectedRowIndex, m_currentRowIndex);
                        int selectionEnd   = Math.Max(m_firstSelectedRowIndex, m_currentRowIndex);
                        SetRowSelection(0, selectionBegin, false);
                        SetRowSelection(selectionBegin, selectionEnd + 1, true);
                        SetRowSelection(selectionEnd + 1, Rows.Count, false);
                    }
                    else
                    {
                        m_firstSelectedRowIndex = -1;
                        if (!m_isControlDown)
                        {
                            SetRowSelection(0, Rows.Count, false);
                        }
                        bool value = !((DataGridViewCustomRow)Rows[m_currentRowIndex]).selected;
                        SetRowSelection(m_currentRowIndex, m_currentRowIndex + 1, value);
                    }
                }
            }
            m_mainSplitContainer.SelectedResultsChanged();
        }