我有一个日历控件,但是单击文本框之后不能自动弹出日历控件,是什么问题呀
程序代码:
//-----显示和选择出生日期,登记日期,有效期----- private void cmb3_DropDown(object sender, System.EventArgs e) { selectDate(cmb3); } private void cmb4_DropDown(object sender, System.EventArgs e) { selectDate(cmb4); } private void cmb5_DropDown(object sender, System.EventArgs e) { selectDate(cmb5); } //----------关闭日期控件的显示---------- private void cmb3_Leave(object sender, System.EventArgs e) { calen1.Visible = false; } private void cmb4_Leave(object sender, System.EventArgs e) { calen1.Visible = false; } private void cmb5_Leave(object sender, System.EventArgs e) { calen1.Visible = false; } //-----------单击下拉列表框下拉箭头时显示日期以供选择--------------- private void selectDate(ComboBox cb) { calen1.Left = cb.Left;//设置日期控件的位置 calen1.Top = cb.Top - calen1.Height - 10; calen1.SelectionStart = Convert.ToDateTime(cb.Text);//日历显示的时间为数据时间 calen1.SelectionEnd = Convert.ToDateTime(cb.Text); calen1.Visible = true;//显示日期 calen1.Show(); } //-----------从日历控件中选择日期信息------------ private void calen1_DateSelected(object sender, System.Windows.Forms.DateRangeEventArgs e) { //判断是由哪个下拉列表框调出日历,以便回馈日期信息 if (calen1.Left == cmb3.Left) cmb3.Text = calen1.SelectionEnd.ToString(); if (calen1.Left == cmb4.Left) cmb4.Text = calen1.SelectionEnd.ToString(); if (calen1.Left == cmb5.Left) cmb5.Text = calen1.SelectionEnd.ToString(); }