本文整理汇总了C#中System.Windows.Forms.TableLayoutPanel.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# TableLayoutPanel.Invoke方法的具体用法?C# TableLayoutPanel.Invoke怎么用?C# TableLayoutPanel.Invoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TableLayoutPanel
的用法示例。
在下文中一共展示了TableLayoutPanel.Invoke方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunVerify
public static void RunVerify(string domainCode, string yearTermCode, TableLayoutPanel tablePanel, ProgressBar progressBar)
{
// Prep report factory for correct student totals.
ReportFactory factory = new ReportFactory();
factory.GetTotalStudentCount(yearTermCode, ref _sqlConn);
// Delete current contents.
tablePanel.Invoke(new MethodInvoker(delegate
{
tablePanel.Controls.Clear();
tablePanel.RowStyles.Clear();
}));
// Grab reports listing.
string sqlCmdStr = "SELECT * FROM [" + WorkingDB + "].[barobba].[" +
ReportTable + "] WHERE [Domain] = '" + domainCode + "';";
SqlCommand sqlCmd = new SqlCommand(sqlCmdStr);
sqlCmd.Connection = _sqlConn;
List<Dictionary<string, string>> reportItems = new List<Dictionary<string,string>>();
SqlDataReader reader = sqlCmd.ExecuteReader();
while (reader.Read())
{
Dictionary<string, string> report = new Dictionary<string, string>(6);
if (report != null)
{
report.Add("Type", reader["Type"].ToString());
report.Add("Command", reader["Command"].ToString());
report.Add("Title", reader["Title"].ToString());
report.Add("Library", reader["Library"].ToString());
report.Add("Item", reader["Item"].ToString());
report.Add("Other", reader["Other"].ToString());
reportItems.Add(report);
}
else
{
MessageBox.Show("Failure executing query for " + domainCode + " item " + reader["Item"].ToString() + ". Please contact technical support.", "Failure Running Report", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
reader.Close();
progressBar.Invoke(new MethodInvoker(delegate { progressBar.Value = 10; }));
int row = 0;
if (reportItems.Count > 0)
{
foreach (Dictionary<string, string> report in reportItems)
{
ITableLayoutRowItem rowItem = factory.NewReport(yearTermCode, report, ref _sqlConn);
tablePanel.Invoke(new MethodInvoker(delegate
{
tablePanel.RowStyles.Add(new RowStyle(SizeType.Absolute, TableLayoutRowHeight));
tablePanel.Controls.Add(rowItem.ControlAt(0), 0, row);
tablePanel.Controls.Add(rowItem.ControlAt(1), 1, row);
tablePanel.Controls.Add(rowItem.ControlAt(2), 2, row);
tablePanel.Controls.Add(rowItem.ControlAt(3), 3, row);
}));
row++;
progressBar.Invoke(new MethodInvoker(delegate { progressBar.Value = 10 + ((90 / reportItems.Count) * row); }));
}
}
else
{
MessageBox.Show("No " + domainCode + " verification reports were found or processed in database. Please contact technical support for more information.", "No Available Reports", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
// Add bottom spacer and set final layout.
tablePanel.Invoke(new MethodInvoker(delegate
{
tablePanel.RowStyles.Add(new RowStyle(SizeType.AutoSize));
tablePanel.RowCount = ++row;
tablePanel.PerformLayout();
tablePanel.VerticalScroll.Enabled = true;
tablePanel.VerticalScroll.Visible = true;
tablePanel.HorizontalScroll.Enabled = false;
tablePanel.HorizontalScroll.Visible = false;
tablePanel.Refresh();
}));
}