本文整理汇总了C#中System.Windows.Forms.DataGridView.PerformLayout方法的典型用法代码示例。如果您正苦于以下问题:C# DataGridView.PerformLayout方法的具体用法?C# DataGridView.PerformLayout怎么用?C# DataGridView.PerformLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.DataGridView
的用法示例。
在下文中一共展示了DataGridView.PerformLayout方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeDataGridView
public static void InitializeDataGridView(DataGridView v,
int colCount, int rowCount,
int columnWidth = 48, int rowHeadersWidth = 64,
string tableName = "", string colName = "", string rowName = "",
bool nocolNum = false, bool noRowNum = false,
bool invertCol = false, bool invertRow = false)
{
v.Rows.Clear();
// Create an unbound DataGridView by declaring a column count.
v.ColumnCount = colCount;
v.ColumnHeadersVisible = true;
// Set the column header style.
DataGridViewCellStyle columnHeaderStyle = new DataGridViewCellStyle();
columnHeaderStyle.BackColor = Color.Beige;
//columnHeaderStyle.Font = new Font("Verdana", 10, FontStyle.Bold);
v.ColumnHeadersDefaultCellStyle = columnHeaderStyle;
string[] row = new string[colCount];
// Set the column header names.
//int c = 1;
for (int i = 0; i < colCount; ++i)
{
string name = colName;
if (!nocolNum)
{
if (invertCol)
{
name += " " + (colCount - i).ToString();
}
else
{
name += " " + (i + 1).ToString();
}
}
v.Columns[i].Name = name;
v.Columns[i].Width = columnWidth;
}
v.RowHeadersWidth = rowHeadersWidth;
v.TopLeftHeaderCell.Value = tableName;
for (int i = 0; i < rowCount; i++)
{
v.Rows.Add(row);
string name = rowName;
if (!noRowNum)
{
if (invertRow)
{
name += " " + (rowCount - i).ToString();
}
else
{
name += " " + (i + 1).ToString();
}
}
v.Rows[i].HeaderCell.Value = name;
}
v.PerformLayout();
}
示例2: LoadDatatoTableWithoutBindWithLable
public void LoadDatatoTableWithoutBindWithLable(DataGridView ObgTbl, String CmdStr, String FnName, Label _Progress)
{
ObgTbl.PerformLayout();
DataTable mytb = new DataTable();
mytb = GetDataTable(CmdStr, FnName);
if (mytb != null)
{
if (mytb.Rows.Count > 0)
{
Int32 NofColoums = mytb.Columns.Count;
String[] ParamCollection = new String[NofColoums];
ObgTbl.Rows.Clear();
for (int i = 0; i < mytb.Rows.Count; i++)
{
Application.DoEvents();
_Progress.Text = mytb.Rows[i][0].ToString();
for (int x = 0; x < NofColoums; x++)
{
string MCX = mytb.Columns[x].DataType.ToString();
if (MCX != "System.DateTime")
ParamCollection[x] = mytb.Rows[i].ItemArray.GetValue(x).ToString();
else
{
DateTime Xdate;
if (string.IsNullOrEmpty(mytb.Rows[i].ItemArray.GetValue(x).ToString()) == false)
Xdate = DateTime.Parse(mytb.Rows[i].ItemArray.GetValue(x).ToString());
else
Xdate = DateTime.MinValue;
ParamCollection[x] = Xdate.ToString("dd/MMM/yyyy");
}
}
try
{
ObgTbl.Rows.Add(ParamCollection);
}
catch (Exception ex)
{
}
}
DocolourThisGrid(ObgTbl);
}
}
else
{
ObgTbl.Rows.Clear();
}
}