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


C# DataGridView.Invalidate方法代码示例

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


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

示例1: ApplyDataGridViewPrefs

        void ApplyDataGridViewPrefs(DataGridView dataGridView, Preferences prefs)
        {
            if (dataGridView.Columns.Count > 1)
            {
                if (prefs.setLastColumnWidth)
                {
                    dataGridView.Columns[dataGridView.Columns.Count - 1].MinimumWidth = prefs.lastColumnWidth;
                }
                else
                {
                    // Workaround for a .NET bug which brings the DataGridView into an unstable state (causing lots of NullReferenceExceptions).
                    dataGridView.FirstDisplayedScrollingColumnIndex = 0;

                    dataGridView.Columns[dataGridView.Columns.Count - 1].MinimumWidth = 5;  // default
                }
            }
            if (dataGridView.RowCount > 0)
            {
                dataGridView.UpdateRowHeightInfo(0, true);
            }
            dataGridView.Invalidate();
            dataGridView.Refresh();
            AutoResizeColumns(dataGridView);
        }
开发者ID:gspatace,项目名称:logexpert,代码行数:24,代码来源:LogWindow.cs

示例2: Update_GridView

 // =================================================================================
 // Forcing a DataGridview display update
 // Ugly hack if you ask me, but MS didn't give us any other reliable way...
 private void Update_GridView(DataGridView Grid) {
     Grid.Invalidate();
     Grid.Update();
 }
开发者ID:jkuusama,项目名称:LitePlacer-ver2,代码行数:7,代码来源:MainForm.cs

示例3: UpDownOrDelete

 private static void UpDownOrDelete(bool? isUp, DataGridView dataGridView1)
 {
     Clips.BoardDataTable clips = null;
     if (dataGridView1 == null
             || dataGridView1.SelectedCells == null
             || dataGridView1.SelectedCells.Count < 1
             || (clips = dataGridView1.DataSource as Clips.BoardDataTable) == null)
         return;
     dataGridView1.SuspendLayout();
     Dictionary<int, int> idxs = new Dictionary<int, int>();
     for (int i = 0; i < dataGridView1.SelectedCells.Count; i++)
         idxs.Add(dataGridView1.SelectedCells[i].RowIndex, -1);
     List<int> rows = new List<int>();
     foreach (int id in idxs.Keys)
         rows.Add(id);
     for (int i = rows.Count - 1; i >= 0; i--)
         if (rows[i] < 0
                 || rows[i] >= dataGridView1.RowCount)
             return;
     rows.Sort();
     if (isUp == null)
     {
         for (int i = rows.Count - 1; i >= 0; i--)
             clips.Rows.RemoveAt(rows[i]);
     }
     else
     {
         int diff = rows[rows.Count - 1] - rows[0];
         int plus = 1;
         int temp = 0;
         for (int i = 1; i < rows.Count; i++)
         {
             if (Math.Abs(rows[i - 1] - rows[i]) == 1)
             {
                 temp++;
                 if (i != rows.Count - 1)
                     continue;
             }
             if (plus < temp)
                 plus = temp;
             temp = 0;
         }
         diff += plus;
         for (int i = 0; i < rows.Count; i++)
             idxs[rows[i]] = rows[i] + (isUp == true ? -diff : diff);
         for (int i = 0; i < rows.Count; i++)
             if (idxs[rows[i]] < 0
                     || idxs[rows[i]] >= dataGridView1.RowCount)
                 return;
         List<Clips.BoardRow> boards = new List<Clips.BoardRow>();
         for (int i = rows.Count - 1; i >= 0; i--)
         {
             Clips.BoardRow board = clips.NewBoardRow();
             board.ItemArray = clips[rows[i]].ItemArray;
             boards.Add(board);
             clips.Rows.RemoveAt(rows[i]);
         }
         for (int i = 0; i < boards.Count; i++)
             clips.Rows.InsertAt(boards[boards.Count - i - 1], idxs[rows[i]]);
         for (int i = 0; i < dataGridView1.SelectedCells.Count; i++)
             dataGridView1.SelectedCells[i--].Selected = false;
         for (int i = 0; i < rows.Count; i++)
             dataGridView1[(int)GridColumns.BoardText, idxs[rows[i]]].Selected = true;
     }
     dataGridView1.Invalidate();
     dataGridView1.ResumeLayout();
 }
开发者ID:onestead,项目名称:tools,代码行数:67,代码来源:MainForm.cs

示例4: ClearSelection

        private void ClearSelection(DataGridView dgv)
        {
            if (dgv.CurrentCell != null)
            {
                dgv.ClearSelection();

                int index = dgv.CurrentRow.Index;
                dgv.CurrentCell = null;
                Rectangle rect = dgv.GetRowDisplayRectangle(index, false);
                rect.Inflate(1, 1);
                dgv.Invalidate(rect);
            }
        }
开发者ID:marcpiulachs,项目名称:noahylk,代码行数:13,代码来源:FormSale.cs


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