Winform靜態加載TabControl用法實例。本站提示廣大學習愛好者:(Winform靜態加載TabControl用法實例)文章只能為提供參考,不一定能成為您想要的結果。以下是Winform靜態加載TabControl用法實例正文
本文實例講述了Winform靜態加載TabControl用法。分享給年夜家供年夜家參考。
詳細完成代碼以下:
private void BindTabData()
{
dtIPD = new DataTable();
//drItem = new DataTable();
//獲得【項目年夜類】列表顯示於 TabPage
MRD_Score model = new MRD_Score();
model.ActiveFlag = "Y";
DataTable dtScore = fmed.GetScoreType(model);
foreach (DataRow dr in dtScore.Rows)
{
MRD_Score sr = new MRD_Score();
sr.PCode = dr["ProCode"].ToString();
TabPage tabpage = new System.Windows.Forms.TabPage(dr["ProName"].ToString().Trim());
tabpage.Name = dr["ProName"].ToString().Trim();
tabpage.AutoScroll = true;
tabpage.Text = dr["ProName"].ToString().Trim();
//獲得年夜類下的 缺點項目列表 txtIPD_NO.Text.Trim()
DataTable drItem = fmed.getScoreItemType(sr.PCode, "");
drItem.Columns.Add("缺點數", Type.GetType("System.Int32"));
drItem.Columns.Add("已審核", Type.GetType("System.Int32"));
drItem.Columns.Add("評分時光", Type.GetType("System.String"));
drItem.Columns.Add("評分人", Type.GetType("System.String"));
drItem.Columns.Add("審核時光", Type.GetType("System.String"));
drItem.Columns.Add("審核人", Type.GetType("System.String"));
DataGridView dgv = new DataGridView();
dgv.AllowUserToAddRows = false;//禁用新增
dgv.AllowUserToDeleteRows = false; //禁用刪除
dgv.Width = 960;
dgv.Height = 600;
dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
dgv.CellValidating += new DataGridViewCellValidatingEventHandler(dgv_CellValidating);//驗證能否為數字
dgv.CellBeginEdit += new DataGridViewCellCancelEventHandler(dgv_CellBeginEdit);// 設置 能否可以編纂
dgv.CellEndEdit += new DataGridViewCellEventHandler(dgv_CellEndEdit);
//dgv.CellFormatting += new DataGridViewCellFormattingEventHandler(dgv_CellFormatting);
dgv.DataSource = drItem;
dtIPD = fmed.getScoreItemType(sr.PCode, txtIPD_NO.Text.Trim());
tabpage.Controls.Add(dgv);
this.tabControl1.Controls.Add(tabpage);
SetInputValue(dgv, dtIPD);//加載曾經輸出的分值
total += getDeFen(dgv, dtIPD);
dgv.Columns["PCode"].Visible = false;
dgv.Columns["ItemCode"].Visible = false;
dgv.Columns["評分人"].Visible = false;
dgv.Columns["審核人"].Visible = false;
}
}
private void GetTolSum()
{
if (tabControl1.TabCount == 0)
{
txtScore.Clear();
txtLevel.Clear();
return;
}
double tolsource = 0.00;
for (int i = 0; i < tabControl1.TabCount; i++)
{
if (!tabControl1.TabPages[i].HasChildren)
{
continue;
}
tolsource += SumDgv((DataGridView)tabControl1.TabPages[i].Controls[0]);
}
GetScoreLevel(tolsource);
SaveTol();
}
願望本文所述對年夜家的C#法式設計有所贊助。