예제 #1
0
        /// <summary>
        /// 时间选择控件值改变事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DateTimePicker_ValueChanged(object sender, EventArgs e)
        {
            DateTimePicker time = (DateTimePicker)sender;

            if (time.Name == this.dtpCreateTime.Name)
            {
                Invokes.SetTextBoxText(this.tbCreateTime, this.dtpCreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
            }
            else
            {
                Invokes.SetTextBoxText(this.tbModifiedTime, this.dtpModifiedTime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
            }
        }
예제 #2
0
        /// <summary>
        /// 时间修改事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TextBoxTime_Leave(object sender, EventArgs e)
        {
            Control ctrl = (Control)sender;

            if (ctrl is TextBox)
            {
                TextBox box = (TextBox)sender;
                if (box.Name == this.tbCreateTime.Name)
                {
                    try
                    {
                        if (!string.IsNullOrEmpty(this.tbCreateTime.Text.Trim()))
                        {
                            _createTime = DateTime.Parse(this.tbCreateTime.Text.Trim());
                        }
                    }
                    catch (Exception)
                    {
                        _createTime = null;
                        Msg("创建时间格式不对");
                        Invokes.SetTextBoxText(this.tbCreateTime, "");
                    }
                }
                else
                {
                    try
                    {
                        if (!string.IsNullOrEmpty(this.tbModifiedTime.Text.Trim()))
                        {
                            _modifiedTime = DateTime.Parse(this.tbModifiedTime.Text.Trim());
                        }
                    }
                    catch (Exception)
                    {
                        _modifiedTime = null;
                        Msg("修改时间格式不对");
                        Invokes.SetTextBoxText(this.tbModifiedTime, "");
                    }
                }
            }
        }
예제 #3
0
 private void setTextBox()
 {
     Invokes.SetTextBoxText(textBox1, textBox2.Text);
 }