本文整理汇总了C#中System.Windows.Forms.DataGridView.SuspendLayout方法的典型用法代码示例。如果您正苦于以下问题:C# DataGridView.SuspendLayout方法的具体用法?C# DataGridView.SuspendLayout怎么用?C# DataGridView.SuspendLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.DataGridView
的用法示例。
在下文中一共展示了DataGridView.SuspendLayout方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetRowsVisibilityByScore
public static void SetRowsVisibilityByScore(DataGridView gridView, double threshold, bool visState)
{
Console.WriteLine("Hiding");
gridView.SuspendLayout();
CurrencyManager currencyManager = gridView.BindingContext[gridView.DataSource] as CurrencyManager;
currencyManager.SuspendBinding();
int timeElapsed = Environment.TickCount;
foreach(DataGridViewRow row in gridView.Rows)
{
int timeTick = Environment.TickCount;
Console.WriteLine("Toggling row {0} - {1}", row, timeTick - timeElapsed);
timeElapsed = timeTick;
try
{
double ms2Score = (double)row.Cells.GetCellValueFromColumnHeader("MS2 Score");
if (ms2Score < threshold)
{
row.Visible = visState;
}
}
catch
{
Console.WriteLine(row);
//row.Visible = false;
}
}
currencyManager.ResumeBinding();
gridView.ResumeLayout();
gridView.Refresh();
}
示例2: fill
private void fill(DataGridView grid, string filter = null)
{
if(!String.IsNullOrWhiteSpace(filter)) {
filter = filter.ToLower();
}
grid.SuspendLayout();
grid.Rows.Clear();
foreach(EnvDTE.Command cmd in _commands)
{
if(String.IsNullOrWhiteSpace(cmd.Name) || (filter != null && !cmd.Name.ToLower().Contains(filter))) {
continue;
}
grid.Rows.Add(cmd.Name);
}
grid.ResumeLayout();
labelPropCount.Text = grid.Rows.Count.ToString();
}
示例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: SetAllCheckboxes
private void SetAllCheckboxes(DataGridView dgv, int checkboxColumnIndex, bool isChecked)
{
dgv.Enabled = false;
dgv.SuspendLayout();
dgv.Rows.Cast<DataGridViewRow>().ToList().ForEach(row =>
{
row.Cells[checkboxColumnIndex].Value = isChecked;
});
dgv.ResumeLayout();
RenderArticleCount();
dgv.Enabled = true;
}
示例5: FilterGridView
public static void FilterGridView(DataGridView vw, string searchstr)
{
vw.SuspendLayout();
DataGridViewRow[] theRows = new DataGridViewRow[vw.Rows.Count];
vw.Rows.CopyTo(theRows, 0);
vw.Rows.Clear();
for (int loop = 0; loop < theRows.Length; loop++)
{
bool found = false;
if (searchstr.Length < 1)
found = true;
else
{
foreach (DataGridViewCell cell in theRows[loop].Cells)
{
if (cell.Value != null)
{
if (cell.Value.ToString().IndexOf(searchstr, 0, StringComparison.CurrentCultureIgnoreCase) >= 0)
{
found = true;
break;
}
}
}
}
theRows[loop].Visible = found;
}
vw.Rows.AddRange(theRows);
vw.ResumeLayout();
}
示例6: SetStyle
/// <summary>
/// Duylnk added: DataGridView
/// </summary>
/// <param name="grd"></param>
public static void SetStyle(DataGridView grd)
{
grd.SuspendLayout();
if (ThemeColor == Style.Blue)
{
grd.BackgroundColor = Color.FromArgb(227, 242, 252);
grd.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(217, 232, 252);//Color.FromArgb(229, 255, 255);//Color.Blue;//Color.MidnightBlue;
grd.ColumnHeadersDefaultCellStyle.ForeColor = Color.MidnightBlue;
grd.RowHeadersDefaultCellStyle.BackColor = Color.FromArgb(217, 232, 252);
grd.DefaultCellStyle.BackColor = Color.FromArgb(227, 242, 252);
grd.DefaultCellStyle.SelectionBackColor = SystemColors.ActiveCaption;
grd.DefaultCellStyle.SelectionForeColor = SystemColors.ActiveCaptionText;
foreach (DataGridViewColumn grdCol in grd.Columns)
{
if (!grdCol.ReadOnly)
{
grdCol.DefaultCellStyle.BackColor = Color.FromArgb(255, 224, 192);
grdCol.DefaultCellStyle.SelectionBackColor = SystemColors.ActiveCaption;
grdCol.DefaultCellStyle.SelectionForeColor = SystemColors.ActiveCaptionText;
}
}
}
grd.ResumeLayout();
}