如题,又或者把把星期换成1,2,3,4,5,6,7
别说换控件,我也知道Infragistics的控件可以
现在是微软自带的DateTimePicker

解决方案 »

  1.   

    DateTimePicker如何控件上的星期
    如题,又或者把把星期换成1,2,3,4,5,6,7
    实在读不懂你在说什么……
      

  2.   

    首先,机器上应该安装有 .NET Framework 对应的英文语言包,一般会默认安装。然后,在需要显示英文 DateTimePicker 控件的窗体,将其主线程设置为英语区域选项。比如,在其构造函数的 InitializeComponent 之后,加一句:System.Threading.Thread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");注意,要改 CurrentUICulture,而不是 CurrentCulture。另外,这个设置会影响被设置线程的其他 UI 行为,比如 Calendar,或者 Exception 信息,都会被显示为英文。http://social.msdn.microsoft.com/Forums/zh-CN/visualcshartzhchs/thread/b3c6a382-4c5c-43c4-89a7-db5b5dfa501b
      

  3.   

    什么跟什么呀,这么设置只会显示Sun,Tue之类的
    没试过,不知道控件支不支持重写
    不过搞不懂你这狗屁要求有什么用
      

  4.   

    昨天在win7跑项目,发现win7上的这个控件的星期变成了周一,周二
    貌似还跟系统的主题有关
      

  5.   


    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.Data;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    //using ComLib;namespace ControlLib
    {
        public partial class UbDateTimePicker : UserControl
        {
            /// <summary>
            /// 定义一个用户自定义事件(在dtpDate_ValueChanged事件之后调用)
            /// </summary>
            public delegate void UserHandler(object sender,System.EventArgs e);
            public event UserHandler OnValueChange;        public UbDateTimePicker()
            {
                InitializeComponent();            
            }        private void UserControl1_Load(object sender, EventArgs e)
            {
                txtDate.Text = dtpDate.Value.Date.ToString("yyyyMMdd");
            }        private void dtpDate_ValueChanged(object sender, EventArgs e)
            {
                txtDate.Text = dtpDate.Value.Date.ToString("yyyyMMdd");
                txtDate.Focus();
                txtDate.DeselectAll();
                if (OnValueChange != null)
                {
                    OnValueChange(sender, e);
                }
            }        protected override void OnEnabledChanged(EventArgs e)
            {
                if (this.Enabled == false)
                {
                    if (txtDate.ReadOnly == true)
                    {
                        txtDate.BackColor = Color.WhiteSmoke;
                    }
                    else
                    {
                        txtDate.BackColor = this.BackColor;
                    }
                }
                else 
                {
                    txtDate.BackColor = Color.White;
                }
                base.OnEnabledChanged(e);
            }        private void txtDate_TextChanged(object sender, EventArgs e)
            {
                if (txtDate.Text == "" || txtDate.Mask == "0000-00" || txtDate.Mask == "0000") return;
                string msg;
                //if (!checkDate(txtDate, out msg, true))
                //{
                //    return;
                //}
                //if (txtDate.Text.Length==8)
                    //dtpDate.Value = ComLibrary.ToDateTime(txtDate.Text); ; //DateTime.Parse(txtDate.Text.ToString()).ToLongDateString();
            }        private void dtpDate_Validated(object sender, EventArgs e)
            {
                txtDate.Text = dtpDate.Value.Date.ToString("yyyyMMdd");
                txtDate.Focus();
                txtDate.DeselectAll();
            }        private void dtpDate_DropDown(object sender, EventArgs e)
            {
                txtDate.Text = dtpDate.Value.Date.ToString("yyyyMMdd");
                txtDate.Focus();
                txtDate.DeselectAll();
            }
           
        }
    }
    俺做个好人,给你重写了一个。
      

  6.   

    设计页面namespace ControlLib
    {
        partial class UbDateTimePicker
        {
            /// <summary> 
            /// Required designer variable.
            /// </summary>
            private System.ComponentModel.IContainer components = null;        /// <summary> 
            /// Clean up any resources being used.
            /// </summary>
            /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
            protected override void Dispose(bool disposing)
            {
                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }        #region Component Designer generated code        /// <summary> 
            /// Required method for Designer support - do not modify 
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
                this.dtpDate = new System.Windows.Forms.DateTimePicker();
                this.txtDate = new ControlLib.UbDateBox();
                this.SuspendLayout();
                // 
                // dtpDate
                // 
                this.dtpDate.CalendarFont = new System.Drawing.Font("SimSun", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
                this.dtpDate.Font = new System.Drawing.Font("SimSun", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
                this.dtpDate.Location = new System.Drawing.Point(0, 0);
                this.dtpDate.Name = "dtpDate";
                this.dtpDate.Size = new System.Drawing.Size(107, 23);
                this.dtpDate.TabIndex = 0;
                this.dtpDate.TabStop = false;
                this.dtpDate.ValueChanged += new System.EventHandler(this.dtpDate_ValueChanged);
                this.dtpDate.Validated += new System.EventHandler(this.dtpDate_Validated);
                this.dtpDate.DropDown += new System.EventHandler(this.dtpDate_DropDown);
                // 
                // txtDate
                // 
                this.txtDate.BorderStyle = System.Windows.Forms.BorderStyle.None;
                this.txtDate.CheckedTiming = ControlLib.InputCheckedTiming.EnterValidating;
                this.txtDate.Font = new System.Drawing.Font("SimSun", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
                this.txtDate.InsertKeyMode = System.Windows.Forms.InsertKeyMode.Overwrite;
                this.txtDate.Location = new System.Drawing.Point(3, 3);
                this.txtDate.Mask = "0000-00-00";
                this.txtDate.Name = "txtDate";
                this.txtDate.NM = "";
                this.txtDate.Size = new System.Drawing.Size(85, 16);
                this.txtDate.TabIndex = 1;
                this.txtDate.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
                this.txtDate.TextMaskFormat = System.Windows.Forms.MaskFormat.ExcludePromptAndLiterals;
                this.txtDate.ToolStripStatusLabel = null;
                this.txtDate.ValidatingType = typeof(System.DateTime);
                this.txtDate.Value = 0;
                this.txtDate.TextChanged += new System.EventHandler(this.txtDate_TextChanged);
                // 
                // UbDateTimePicker
                // 
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.Controls.Add(this.txtDate);
                this.Controls.Add(this.dtpDate);
                this.Name = "UbDateTimePicker";
                this.Size = new System.Drawing.Size(107, 21);
                this.Load += new System.EventHandler(this.UserControl1_Load);
                this.ResumeLayout(false);
                this.PerformLayout();        }        #endregion        public UbDateBox txtDate;
            public System.Windows.Forms.DateTimePicker dtpDate;
        }
    }