"
未将对象引用设置到对象的实例"
private DateTime dt;
private void btnOK_Click(object sender, EventArgs e)
{
dt = new DateTime(DateTime.Now.Year,DateTime.Now.Month,DateTime.Now.Day,(int)cbbHour.SelectedValue,(int)cbbMinute.SelectedValue,0,0);
//string ss=txtRemind.Text;
timer1.Enabled=true;
}
private void timer1_Tick(object sender, EventArgs e)
{
if (DateTime.Now == dt)
{
MessageBox.Show("时间到了!");
timer1.Enabled=false;
}
}
------解决方案--------------------
dt = new DateTime(DateTime.Now.Year,DateTime.Now.Month,DateTime.Now.Day,(int)cbbHour.SelectedValue,(int)cbbMinute.SelectedValue,0,0);
明显红色部分出现了null情况