/// ------------------------------------------------------------------------------------
 /// <summary>
 /// Don't allow the cell to have the selection color.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 protected override void Paint(Graphics graphics, Rectangle clipBounds,
                               Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState,
                               object value, object formattedValue, string errorText,
                               DataGridViewCellStyle cellStyle,
                               DataGridViewAdvancedBorderStyle advancedBorderStyle,
                               DataGridViewPaintParts paintParts)
 {
     SilHierarchicalGridRow.Fill(graphics, cellBounds, DataGridView);
 }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void SetExpandedState(bool expanded, bool force, bool suspendAndResumeLayout)
        {
            if (m_expanded == expanded && !force)
            {
                return;
            }

            m_expanded = expanded;

            if (m_owningGrid == null || Index == m_owningGrid.Rows.Count - 1)
            {
                return;
            }

            if (suspendAndResumeLayout)
            {
                Utils.SetWindowRedraw(m_owningGrid, false, false);
            }

            // Make hide or unhide all rows between this one and the next SilHierarchicalGridRow
            // at the same level or higher or the end of the list, whatever comes first.
            for (int i = Index + 1; i < m_owningGrid.Rows.Count; i++)
            {
                SilHierarchicalGridRow row = m_owningGrid.Rows[i] as SilHierarchicalGridRow;

                if (row != null && row.Level <= m_level)
                {
                    break;
                }

                m_owningGrid.Rows[i].Visible = m_expanded;
            }

            if (ExpandedStateChanged != null)
            {
                ExpandedStateChanged(this);
            }

            if (suspendAndResumeLayout)
            {
                Utils.SetWindowRedraw(m_owningGrid, true, true);
            }
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates an exact copy of the row.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public override object Clone()
        {
            object clone = base.Clone();

            if (clone is SilHierarchicalGridRow)
            {
                SilHierarchicalGridRow row = clone as SilHierarchicalGridRow;
                row.m_owningGrid      = m_owningGrid;
                row.m_expanded        = m_expanded;
                row.m_glyphWidth      = m_glyphWidth;
                row.m_glyphHeight     = m_glyphHeight;
                row.m_text            = m_text;
                row.m_font            = m_font;
                row.m_level           = m_level;
                row.m_childCount      = m_childCount;
                row.m_firstCacheIndex = m_firstCacheIndex;
                row.m_lastCacheIndex  = m_lastCacheIndex;
                row.m_recCountFmt     = m_recCountFmt;
            }

            return(clone);
        }