当前位置: 首页>>代码示例>>C#>>正文


C# DataGridViewRow.GetHeight方法代码示例

本文整理汇总了C#中System.Windows.Forms.DataGridViewRow.GetHeight方法的典型用法代码示例。如果您正苦于以下问题:C# DataGridViewRow.GetHeight方法的具体用法?C# DataGridViewRow.GetHeight怎么用?C# DataGridViewRow.GetHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.DataGridViewRow的用法示例。


在下文中一共展示了DataGridViewRow.GetHeight方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateRowCaches

 private void UpdateRowCaches(int rowIndex, ref DataGridViewRow dataGridViewRow, bool adding)
 {
     if (((this.rowCountsVisible != -1) || (this.rowCountsVisibleFrozen != -1)) || (((this.rowCountsVisibleSelected != -1) || (this.rowsHeightVisible != -1)) || (this.rowsHeightVisibleFrozen != -1)))
     {
         DataGridViewElementStates rowState = this.GetRowState(rowIndex);
         if ((rowState & DataGridViewElementStates.Visible) != DataGridViewElementStates.None)
         {
             int num = adding ? 1 : -1;
             int num2 = 0;
             if ((this.rowsHeightVisible != -1) || ((this.rowsHeightVisibleFrozen != -1) && ((rowState & (DataGridViewElementStates.Visible | DataGridViewElementStates.Frozen)) == (DataGridViewElementStates.Visible | DataGridViewElementStates.Frozen))))
             {
                 num2 = adding ? dataGridViewRow.GetHeight(rowIndex) : -dataGridViewRow.GetHeight(rowIndex);
                 dataGridViewRow = this.SharedRow(rowIndex);
             }
             if (this.rowCountsVisible != -1)
             {
                 this.rowCountsVisible += num;
             }
             if (this.rowsHeightVisible != -1)
             {
                 this.rowsHeightVisible += num2;
             }
             if ((rowState & (DataGridViewElementStates.Visible | DataGridViewElementStates.Frozen)) == (DataGridViewElementStates.Visible | DataGridViewElementStates.Frozen))
             {
                 if (this.rowCountsVisibleFrozen != -1)
                 {
                     this.rowCountsVisibleFrozen += num;
                 }
                 if (this.rowsHeightVisibleFrozen != -1)
                 {
                     this.rowsHeightVisibleFrozen += num2;
                 }
             }
             if (((rowState & (DataGridViewElementStates.Visible | DataGridViewElementStates.Selected)) == (DataGridViewElementStates.Visible | DataGridViewElementStates.Selected)) && (this.rowCountsVisibleSelected != -1))
             {
                 this.rowCountsVisibleSelected += num;
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:40,代码来源:DataGridViewRowCollection.cs

示例2: UpdateRowCaches

        private void UpdateRowCaches(int rowIndex, ref DataGridViewRow dataGridViewRow, bool adding)
        {
            if (this.rowCountsVisible != -1 || this.rowCountsVisibleFrozen != -1 || this.rowCountsVisibleSelected != -1 ||
                this.rowsHeightVisible != -1 || this.rowsHeightVisibleFrozen != -1)
            {
                DataGridViewElementStates rowStates = GetRowState(rowIndex);
                if ((rowStates & DataGridViewElementStates.Visible) != 0)
                {
                    int rowCountIncrement = adding ? 1 : -1;
                    int rowHeightIncrement = 0;
                    if (this.rowsHeightVisible != -1 || 
                        (this.rowsHeightVisibleFrozen != -1 && 
                         ((rowStates & (DataGridViewElementStates.Visible | DataGridViewElementStates.Frozen)) == (DataGridViewElementStates.Visible | DataGridViewElementStates.Frozen))))
                    {
                        // dataGridViewRow may become unshared in GetHeight call
                        rowHeightIncrement = adding ? dataGridViewRow.GetHeight(rowIndex) : -dataGridViewRow.GetHeight(rowIndex);
                        dataGridViewRow = SharedRow(rowIndex);
                    }
                    
                    if (this.rowCountsVisible != -1)
                    {
                        this.rowCountsVisible += rowCountIncrement;
                    }
                    if (this.rowsHeightVisible != -1)
                    {
                        Debug.Assert(rowHeightIncrement != 0);
                        this.rowsHeightVisible += rowHeightIncrement;
                    }
                    
                    if ((rowStates & (DataGridViewElementStates.Visible | DataGridViewElementStates.Frozen)) == (DataGridViewElementStates.Visible | DataGridViewElementStates.Frozen))
                    {
                        if (this.rowCountsVisibleFrozen != -1)
                        {
                            this.rowCountsVisibleFrozen += rowCountIncrement;
                        }
                        if (this.rowsHeightVisibleFrozen != -1)
                        {
                            Debug.Assert(rowHeightIncrement != 0);
                            this.rowsHeightVisibleFrozen += rowHeightIncrement;
                        }
                    }

                    if ((rowStates & (DataGridViewElementStates.Visible | DataGridViewElementStates.Selected)) == (DataGridViewElementStates.Visible | DataGridViewElementStates.Selected))
                    {
                        if (this.rowCountsVisibleSelected != -1)
                        {
                            this.rowCountsVisibleSelected += rowCountIncrement;
                        }
                    }
                }
            }

#if DEBUG
            this.cachedRowCountsAccessAllowed = true;
            this.cachedRowHeightsAccessAllowed = true;
#endif
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:57,代码来源:DataGridViewRowCollection.cs

示例3: OnCollectionChanged_PreNotification

        private void OnCollectionChanged_PreNotification(CollectionChangeAction cca, int rowIndex, int rowCount, ref DataGridViewRow dataGridViewRow, bool changeIsInsertion)
        {
            int height;
            bool useRowShortcut = false;
            bool computeVisibleRows = false;
            switch (cca)
            {
                case CollectionChangeAction.Add:
                    height = 0;
                    this.UpdateRowCaches(rowIndex, ref dataGridViewRow, true);
                    if ((this.GetRowState(rowIndex) & DataGridViewElementStates.Visible) != DataGridViewElementStates.None)
                    {
                        int firstDisplayedRowIndex = this.DataGridView.FirstDisplayedRowIndex;
                        if (firstDisplayedRowIndex != -1)
                        {
                            height = this.SharedRow(firstDisplayedRowIndex).GetHeight(firstDisplayedRowIndex);
                        }
                        break;
                    }
                    useRowShortcut = true;
                    computeVisibleRows = changeIsInsertion;
                    break;

                case CollectionChangeAction.Remove:
                {
                    DataGridViewElementStates rowState = this.GetRowState(rowIndex);
                    bool flag3 = (rowState & DataGridViewElementStates.Visible) != DataGridViewElementStates.None;
                    bool flag4 = (rowState & DataGridViewElementStates.Frozen) != DataGridViewElementStates.None;
                    this.rowStates.RemoveAt(rowIndex);
                    this.SharedList.RemoveAt(rowIndex);
                    this.DataGridView.OnRemovedRow_PreNotification(rowIndex);
                    if (!flag3)
                    {
                        useRowShortcut = true;
                    }
                    else if (!flag4)
                    {
                        if ((this.DataGridView.FirstDisplayedScrollingRowIndex != -1) && (rowIndex > this.DataGridView.FirstDisplayedScrollingRowIndex))
                        {
                            int num4 = 0;
                            int num5 = this.DataGridView.FirstDisplayedRowIndex;
                            if (num5 != -1)
                            {
                                num4 = this.SharedRow(num5).GetHeight(num5);
                            }
                            useRowShortcut = this.GetRowsHeightExceedLimit(DataGridViewElementStates.Visible, 0, rowIndex, (this.DataGridView.LayoutInfo.Data.Height + this.DataGridView.VerticalScrollingOffset) + SystemInformation.HorizontalScrollBarHeight) && (num4 <= this.DataGridView.LayoutInfo.Data.Height);
                        }
                    }
                    else
                    {
                        useRowShortcut = (this.DataGridView.FirstDisplayedScrollingRowIndex == -1) && this.GetRowsHeightExceedLimit(DataGridViewElementStates.Visible, 0, rowIndex, this.DataGridView.LayoutInfo.Data.Height + SystemInformation.HorizontalScrollBarHeight);
                    }
                    goto Label_02DF;
                }
                case CollectionChangeAction.Refresh:
                    this.InvalidateCachedRowCounts();
                    this.InvalidateCachedRowsHeights();
                    goto Label_02DF;

                default:
                    goto Label_02DF;
            }
            if (changeIsInsertion)
            {
                this.DataGridView.OnInsertedRow_PreNotification(rowIndex, 1);
                if (!useRowShortcut)
                {
                    if ((this.GetRowState(rowIndex) & DataGridViewElementStates.Frozen) != DataGridViewElementStates.None)
                    {
                        useRowShortcut = (this.DataGridView.FirstDisplayedScrollingRowIndex == -1) && this.GetRowsHeightExceedLimit(DataGridViewElementStates.Visible, 0, rowIndex, this.DataGridView.LayoutInfo.Data.Height);
                    }
                    else if ((this.DataGridView.FirstDisplayedScrollingRowIndex != -1) && (rowIndex > this.DataGridView.FirstDisplayedScrollingRowIndex))
                    {
                        useRowShortcut = this.GetRowsHeightExceedLimit(DataGridViewElementStates.Visible, 0, rowIndex, this.DataGridView.LayoutInfo.Data.Height + this.DataGridView.VerticalScrollingOffset) && (height <= this.DataGridView.LayoutInfo.Data.Height);
                    }
                }
            }
            else
            {
                this.DataGridView.OnAddedRow_PreNotification(rowIndex);
                if (!useRowShortcut)
                {
                    int num3 = (this.GetRowsHeight(DataGridViewElementStates.Visible) - this.DataGridView.VerticalScrollingOffset) - dataGridViewRow.GetHeight(rowIndex);
                    dataGridViewRow = this.SharedRow(rowIndex);
                    useRowShortcut = (this.DataGridView.LayoutInfo.Data.Height < num3) && (height <= this.DataGridView.LayoutInfo.Data.Height);
                }
            }
        Label_02DF:
            this.DataGridView.ResetUIState(useRowShortcut, computeVisibleRows);
        }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:90,代码来源:DataGridViewRowCollection.cs

示例4: OnCollectionChanged_PreNotification

        private void OnCollectionChanged_PreNotification(CollectionChangeAction cca, 
                                                         int rowIndex,
                                                         int rowCount,
                                                         ref DataGridViewRow dataGridViewRow, 
                                                         bool changeIsInsertion)
        {
            Debug.Assert(this.DataGridView != null);
            bool useRowShortcut = false;
            bool computeVisibleRows = false;
            switch (cca)
            {
                case CollectionChangeAction.Add:
                {
                    int firstDisplayedRowHeight = 0;
                    UpdateRowCaches(rowIndex, ref dataGridViewRow, true);
                    if ((GetRowState(rowIndex) & DataGridViewElementStates.Visible) == 0)
                    {
                        // Adding an invisible row - no need for repaint
                        useRowShortcut = true;
                        computeVisibleRows = changeIsInsertion;
                    }
                    else
                    {
                        int firstDisplayedRowIndex = this.DataGridView.FirstDisplayedRowIndex;
                        if (firstDisplayedRowIndex != -1)
                        {
                            firstDisplayedRowHeight = SharedRow(firstDisplayedRowIndex).GetHeight(firstDisplayedRowIndex);
                        }
                    }
                    if (changeIsInsertion)
                    {
                        this.DataGridView.OnInsertedRow_PreNotification(rowIndex, 1);
                        if (!useRowShortcut)
                        {
                            if ((GetRowState(rowIndex) & DataGridViewElementStates.Frozen) != 0)
                            {
                                // Inserted row is frozen
                                useRowShortcut = this.DataGridView.FirstDisplayedScrollingRowIndex == -1 && 
                                                 GetRowsHeightExceedLimit(DataGridViewElementStates.Visible, 0, rowIndex, this.DataGridView.LayoutInfo.Data.Height);
                            }
                            else if (this.DataGridView.FirstDisplayedScrollingRowIndex != -1 &&
                                     rowIndex > this.DataGridView.FirstDisplayedScrollingRowIndex)
                            {
                                useRowShortcut = GetRowsHeightExceedLimit(DataGridViewElementStates.Visible, 0, rowIndex, this.DataGridView.LayoutInfo.Data.Height + this.DataGridView.VerticalScrollingOffset) &&
                                                 firstDisplayedRowHeight <= this.DataGridView.LayoutInfo.Data.Height;
                            }
                        }
                    }
                    else
                    {
                        this.DataGridView.OnAddedRow_PreNotification(rowIndex);
                        if (!useRowShortcut)
                        {
                            int displayedRowsHeightBeforeAddition = GetRowsHeight(DataGridViewElementStates.Visible) - this.DataGridView.VerticalScrollingOffset - dataGridViewRow.GetHeight(rowIndex);
                            dataGridViewRow = SharedRow(rowIndex);
                            useRowShortcut = this.DataGridView.LayoutInfo.Data.Height < displayedRowsHeightBeforeAddition &&
                                             firstDisplayedRowHeight <= this.DataGridView.LayoutInfo.Data.Height;
                        }
                    }
                    break;
                }

                case CollectionChangeAction.Remove:
                {
                    Debug.Assert(rowCount == 1);
                    DataGridViewElementStates rowStates = GetRowState(rowIndex);
                    bool deletedRowVisible = (rowStates & DataGridViewElementStates.Visible) != 0;
                    bool deletedRowFrozen = (rowStates & DataGridViewElementStates.Frozen) != 0;

                    // Can't do this earlier since it would break UpdateRowCaches
                    this.rowStates.RemoveAt(rowIndex);
                    this.SharedList.RemoveAt(rowIndex);
#if DEBUG
                    this.DataGridView.dataStoreAccessAllowed = false;
#endif
                    this.DataGridView.OnRemovedRow_PreNotification(rowIndex);
                    if (deletedRowVisible)
                    {
                        if (deletedRowFrozen)
                        {
                            // Delete row is frozen
                            useRowShortcut = this.DataGridView.FirstDisplayedScrollingRowIndex == -1 &&
                                             GetRowsHeightExceedLimit(DataGridViewElementStates.Visible, 0, rowIndex, this.DataGridView.LayoutInfo.Data.Height + SystemInformation.HorizontalScrollBarHeight);
                        }
                        else if (this.DataGridView.FirstDisplayedScrollingRowIndex != -1 &&
                                 rowIndex > this.DataGridView.FirstDisplayedScrollingRowIndex)
                        {
                            int firstDisplayedRowHeight = 0;
                            int firstDisplayedRowIndex = this.DataGridView.FirstDisplayedRowIndex;
                            if (firstDisplayedRowIndex != -1)
                            {
                                firstDisplayedRowHeight = SharedRow(firstDisplayedRowIndex).GetHeight(firstDisplayedRowIndex);
                            }
                            useRowShortcut = GetRowsHeightExceedLimit(DataGridViewElementStates.Visible, 0, rowIndex, this.DataGridView.LayoutInfo.Data.Height + this.DataGridView.VerticalScrollingOffset + SystemInformation.HorizontalScrollBarHeight) &&
                                             firstDisplayedRowHeight <= this.DataGridView.LayoutInfo.Data.Height;
                        }
                    }
                    else
                    {
                        // Deleting an invisible row - no need for repaint
//.........这里部分代码省略.........
开发者ID:JianwenSun,项目名称:cc,代码行数:101,代码来源:DataGridViewRowCollection.cs


注:本文中的System.Windows.Forms.DataGridViewRow.GetHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。