资 源 简 介
C# 进度条、状态栏和计时器的实例,这个例子的部分功能需要连接数据库才可看到,窗体上可看到进度条、时间等控件的效果,相关代码可看下边的代码,可起一定参考:
myAdapter.Fill(myDs, "dtMyProd");
myConn.Close();
//为数据表生成主键
DataColumn[] myPK = new DataColumn[1];
myPK[0] = myDs.Tables["dtMyProd"].Columns["ProductId"];
myDs.Tables["dtMyProd"].PrimaryKey = myPK;
DataRow thisRow = myDs.Tables["dtMyProd"].Rows[1];
txtPId.Text = "" + thisRow["ProductId"];
txtPName.Text = (String)thisRow["ProductName"];
txtUnitPrice.Text = "$" + thisRow["UnitPrice"];
statusBar1.Text ="数据库加载完毕";
时间处理方面,请参见以下代码:
string TimeInString="";
int hour=DateTime.Now.Hour;
int min=DateTime.Now.Minute;
int sec=DateTime.Now.Second;
TimeInString=(hour < 10)?"0" + hour.ToString() :hour.ToString();
TimeInString+=":" + ((min<10)?"0" + min.ToString() :min.ToString());
TimeInString+=":" + ((sec<10)?"0" + sec.ToString() :sec.ToString());
return TimeInString;