本文整理汇总了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);
}
示例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();
}
示例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();
}
示例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);
}
}