当前位置: 首页>>代码示例>>C#>>正文


C# DateTimePicker.Focus方法代码示例

本文整理汇总了C#中System.Windows.Forms.DateTimePicker.Focus方法的典型用法代码示例。如果您正苦于以下问题:C# DateTimePicker.Focus方法的具体用法?C# DateTimePicker.Focus怎么用?C# DateTimePicker.Focus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.DateTimePicker的用法示例。


在下文中一共展示了DateTimePicker.Focus方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsDateRange

        // Checks date format and range.
        public static bool IsDateRange(DateTimePicker dStart, DateTimePicker dEnd)
        {
            DateTime start= Convert.ToDateTime(dStart.Text) ;
            DateTime end = Convert.ToDateTime(dEnd.Text);
            DateTime today = DateTime.Today;

            if (start<today)
            {
                MessageBox.Show(" The start date can not be before today.", title);
                dStart.Focus();
                return false;
            }

            if (end < today)
            {
                MessageBox.Show(" The end date can not be before today.", title);
                dStart.Focus();
                return false;
            }

            if (start > end)
            {
                MessageBox.Show(" The start date can not be after the end date.", title);
                dStart.Focus();
                return false;
            }
            return true;
        }
开发者ID:dostap,项目名称:OOSD_project2,代码行数:29,代码来源:Validator.cs

示例2: IsValidTimeRange

        public static bool IsValidTimeRange(DateTimePicker dtpStartTime, DateTimePicker dtpEndTime, NumericUpDown numericUpDown)
        {
            // Check if the start time is after the end time.
            if (dtpStartTime.Value > dtpEndTime.Value)
            {
                MessageBox.Show("The end time must be greater than the start time.", "Entry Error", MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                dtpEndTime.Focus();
                return false;
            }

            // TODO: Bug - The date time picker does not roll back to the previous day if the default
            // end time is set for the next day. For example, if we start the program at 8:00 PM, the
            // end time will be set for 12:00 AM the next day. This causes the validation to pass even
            // if the form shows that the time range is too small.

            // Check if at least two time slots can fit in the time range.
            TimeSpan twoTimeSlotsSpan = TimeSpan.FromMinutes((int) numericUpDown.Value * 2);
            if (dtpEndTime.Value - dtpStartTime.Value < twoTimeSlotsSpan)
            {
                MessageBox.Show("The difference between the start and end time must provide for at least two time slots.", "Entry Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                dtpEndTime.Focus();
                return false;
            }

            return true;
        }
开发者ID:masonelmore,项目名称:TicketQueue,代码行数:28,代码来源:Validator.cs

示例3: validateDate

 private bool validateDate(DateTimePicker date)
 {
     if (date.Value > DateTime.Now)
     {
         Helper.showMessage("Date cannot be in future");
         date.Focus();
         return false;
     }
     return true;
 }
开发者ID:srinivasanrm,项目名称:ExpenseMonitor,代码行数:10,代码来源:frmMain.cs


注:本文中的System.Windows.Forms.DateTimePicker.Focus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。