본문 바로가기

   
Programming/Winform

Select, 달력컨트롤, DateTimePicker

반응형
사용자에게 숫자만 입력받을때는 Select 컨트롤을 사용하는 것이 좋다. 각종 검사를 할때 Select는 숫자만 입력할수 있다.




using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

 

namespace Start

{

       public partial class Select : Form

       {

             public Select()

             {

                    InitializeComponent();

             }

 

             private void button1_Click(object sender, EventArgs e)

             {

                    MessageBox.Show(numericUpDown1.Value.ToString());

             }

 

             private void button3_Click(object sender, EventArgs e)

             {

                    //monthCalendar1.SelectionStart

                    //monthCalendar1.SelectionEnd

                    label5.Text = monthCalendar1.SelectionStart.ToLongDateString();

             }

 

             private void button4_Click(object sender, EventArgs e)

             {

                    DateTime christmas = new DateTime(2012, 12, 25);

                    label6.Text = christmas.ToLongDateString();

                    monthCalendar1.SelectionStart = christmas;

             }

 

             private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)

             {

                    label7.Text = monthCalendar1.SelectionStart.ToLongDateString();

             }

 

             private void monthCalendar1_DateSelected(object sender, DateRangeEventArgs e)

             {

                    label8.Text = monthCalendar1.SelectionStart.ToLongDateString();

             }

 

             private void Select_Load(object sender, EventArgs e)

             {

                    //기념일 추가

                    //2012-05-15

                    //2012-06-30

 

                    DateTime[] dates = new DateTime[2];

                    dates[0] = new DateTime(2012, 5, 15);

                    dates[1] = new DateTime(2012, 6, 30);

                    monthCalendar2.MonthlyBoldedDates = dates;

             }

       }

}

 

 


반응형