好的,所以在表单加载时,我调用了一个启动计时器的方法,假设每个刻度都增加一个整数值并将文本框字段 text = 设置为 integer.ToString 并且由于某种原因它增加 4 而不是 1。 …………
/// <summary>
/// Starts the Timer >:D
/// </summary>
public void StartCounting()
{
t.Interval = 1000;
t.Tick += new System.EventHandler(OnTimerEvent);
t.Start();
}
/// <summary>
/// This is what Happens when the timer ticks.
/// </summary>
/// <param name="source"></param>
/// <param name="e"></param>
public void OnTimerEvent(object source, EventArgs e)
{
textBoxActual.Text = currentMinute.ToString();
currentMinute = currentMinute + 1 ;
}
绿色的数字是 textBoxActual <.<
这是我的表单加载代码:
private void Form1_Load(object sender, EventArgs e)
{
Order o = new Order();
StartedOrders = o.GetUnfinishedOrders();
PopulateGrid(StartedOrders, dataGridViewStartedOrders);
//Set the top row to be some abstract style.
System.Windows.Forms.DataGridViewCellStyle iStyle = new DataGridViewCellStyle();
iStyle.BackColor = Color.Green;
System.Drawing.Font f = new System.Drawing.Font("Times New Roman",13,FontStyle.Bold);
iStyle.Font = f;
dataGridViewStartedOrders.Rows[0].DefaultCellStyle = iStyle;
dataGridViewStartedOrders.ClearSelection();
try
{
textBoxOrderNumber.Text = "O# " + dataGridViewStartedOrders.Rows[0].Cells[1].Value.ToString();
textBoxCustomerName.Text = dataGridViewStartedOrders.Rows[0].Cells[2].Value.ToString();
textBoxTarget.Text = dataGridViewStartedOrders.Rows[0].Cells[5].Value.ToString();
textBoxActual.Text = "0";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
StartCounting();
}