當前位置: 首頁>>代碼示例>>C#>>正文


C# MonthCalendar.SetDate方法代碼示例

本文整理匯總了C#中System.Windows.Forms.MonthCalendar.SetDate方法的典型用法代碼示例。如果您正苦於以下問題:C# MonthCalendar.SetDate方法的具體用法?C# MonthCalendar.SetDate怎麽用?C# MonthCalendar.SetDate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Forms.MonthCalendar的用法示例。


在下文中一共展示了MonthCalendar.SetDate方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: control_MouseDown

        private void control_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            ControlFactory factory = ControlFactory.Instance;
            if (e.Button == MouseButtons.Left)
            {
                Field field = factory.GetAssociatedField((Control)sender);
                if (field != null)
                {
                    control = (Control)sender;
                    if (field is DateField || field is DateTimeField)
                    {
                            if (!factory.IsPopup)
                        {
                            MonthCalendar customMonthCalendar = new MonthCalendar();
                            customMonthCalendar.DateSelected += new DateRangeEventHandler(customMonthCalendar_DateSelected);
                            customMonthCalendar.Size = new Size(226, 160);
                            int panelbottom = control.Parent.Bottom;
                            int top = control.Location.Y; int right = control.Parent.Right; int left = control.Left;
                            if (panelbottom - top > 185)//checking to see if the Datefield at the bottom of the canvas
                            {
                                if (right - left < 228)//if field is at the right most part of the canvas.
                                    customMonthCalendar.Location = new Point(right - 230, top + 25);
                                else
                                    customMonthCalendar.Location = new Point(control.Location.X - 10, top + 25);
                            }
                            else//if the datefield is very bottom of the canvas and no enough room for popup.
                                if (right - left < 228)  //if field is at the right and bottom most part of the canvas.
                                    customMonthCalendar.Location = new Point(right - 230, top - 165);
                            else
                                customMonthCalendar.Location = new Point(control.Location.X - 10, control.Top - 165);

                            try
                            {
                                control.Parent.Controls.Add(customMonthCalendar);
                                DateTime datetime ;
                                bool isdatetimeparse= DateTime.TryParse(control.Text, out datetime);
                                if (isdatetimeparse)
                                    customMonthCalendar.SetDate(datetime);
                                customMonthCalendar.Visible = true;
                                customMonthCalendar.BringToFront();
                                factory.IsPopup = true;
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                    }
                }
            }
        }
開發者ID:NALSS,項目名稱:epiinfo-82474,代碼行數:50,代碼來源:Canvas.control.events.cs

示例2: DateChangedEventTest

		public void DateChangedEventTest ()
		{
			MonthCalendar myCalendar = new MonthCalendar ();
			
			myCalendar.Tag = false;
			myCalendar.DateChanged += new DateRangeEventHandler (DateChangedEventHandler);
			myCalendar.SetDate (DateTime.Today.AddDays (72));
			Assert.AreEqual (true, (bool) myCalendar.Tag, "#01");
		}
開發者ID:Profit0004,項目名稱:mono,代碼行數:9,代碼來源:MonthCalendarTest.cs

示例3: PopupCalendar

 private void PopupCalendar(object sender, Point location)
 {
     ControlFactory factory = ControlFactory.Instance;
     if (!factory.IsPopup)
     {
         DataGridView grid = (DataGridView)control;
         MonthCalendar customMonthCalendar = new MonthCalendar();
         customMonthCalendar.DateSelected += new DateRangeEventHandler(dataGridview_customMonthCalendar_DateSelected);
         customMonthCalendar.Size = new Size(226, 160);
         int panelbottom = ((Control)sender).Parent.Bottom; int panelright = ((Control)sender).Parent.Right;
         int top = grid.GetCellDisplayRectangle(grid.SelectedCells[0].ColumnIndex, grid.SelectedCells[0].RowIndex, true).Y;
         int x = grid.GetCellDisplayRectangle(grid.SelectedCells[0].ColumnIndex, grid.SelectedCells[0].RowIndex, true).X;
         if (panelbottom - grid.Top > 165)
         {
             if(panelright-grid.Left<228)
                 customMonthCalendar.Location = new Point((grid.Location.X + x) - 226, grid.Location.Y + top + 25);
             else
                 customMonthCalendar.Location = new Point((grid.Location.X + x) - 10, grid.Location.Y + top + 25);
         }
         else
             if (panelright - grid.Left < 228)
                 customMonthCalendar.Location = new Point((grid.Location.X + x) - 226, grid.Location.Y + top + 25);
             else
             customMonthCalendar.Location = new Point((grid.Location.X + x) - 10, (grid.Location.Y + top) - 165);
         ((Control)sender).Parent.Controls.Add(customMonthCalendar);
         DateTime datetime;
         bool isdatetimeparse = DateTime.TryParse(grid.SelectedCells[0].Value.ToString(), out datetime);
         if (isdatetimeparse)
             customMonthCalendar.SetDate(datetime);
         customMonthCalendar.Visible = true;
         customMonthCalendar.BringToFront();
         factory.IsPopup = true;
     }
 }
開發者ID:NALSS,項目名稱:epiinfo-82474,代碼行數:34,代碼來源:Canvas.control.events.cs

示例4: calender

        public static int calender(OptsType opts, ArgsType args)
        {
            Form f = new Form();

              Panel p = new Panel();
              p.Height = 24;
              p.Dock = DockStyle.Bottom;
              f.Controls.Add(p);

              Button b1 = new Button();
              b1.DialogResult = DialogResult.OK;
              b1.Dock = DockStyle.Fill;
              b1.Text = "&OK";
              p.Controls.Add(b1);

              int year = DateTime.Now.Year;
              if (opts.ContainsKey("year")) {
            int val;
            if (int.TryParse(opts["year"], out val)) {
              year = val;
            }
              }

              int month = DateTime.Now.Month;
              if (opts.ContainsKey("month")) {
            int val;
            if (int.TryParse(opts["month"], out val)) {
              month = val;
            }
              }

              int day = DateTime.Now.Day;
              if (opts.ContainsKey("day")) {
            int val;
            if (int.TryParse(opts["day"], out val)) {
              day = val;
            }
              }

              MonthCalendar mc = new MonthCalendar();
              mc.CalendarDimensions = new Size(1, 1);
              mc.MaxSelectionCount = 42;
              mc.SetDate(new DateTime(year, month, day));
              f.Controls.Add(mc);

              f.Text = "fwfw calender";
              if (opts.ContainsKey("title")) {
            f.Text = opts["title"];
              }
              f.MaximizeBox = false;
              f.FormBorderStyle = FormBorderStyle.FixedDialog;
              f.StartPosition = FormStartPosition.CenterScreen;
              f.ClientSize = mc.Size;
              f.Height = f.Height + p.Height;

              if (f.ShowDialog() != DialogResult.OK) {
            return 1;
              }

              var start = mc.SelectionStart.ToShortDateString().Replace('/', '-');
              var end = mc.SelectionEnd.ToShortDateString().Replace('/', '-');

              Console.Out.WriteLine(start);
              if (start != end) {
            Console.Out.WriteLine(end);
              }

              return 0;
        }
開發者ID:dyama,項目名稱:fwfw,代碼行數:69,代碼來源:calender.cs


注:本文中的System.Windows.Forms.MonthCalendar.SetDate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。