當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。