关于datetimepicker的显示问题

IsaacV_ 2017-05-22 10:44:06

首先,贴张图片,证明我电脑还是能正确显示的。。。


出问题的就是这两个框。。现在是设计的时候,看起来没问题吧。

            // 
// LogTimeBegin
//
this.LogTimeBegin.CustomFormat = "yyyy-MM-dd HH:mm:ss";
this.LogTimeBegin.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.LogTimeBegin.Location = new System.Drawing.Point(110, 15);
this.LogTimeBegin.Name = "LogTimeBegin";
this.LogTimeBegin.Size = new System.Drawing.Size(163, 21);
this.LogTimeBegin.TabIndex = 14;
//
// LogTimeEnd
//
this.LogTimeEnd.CustomFormat = "yyyy-MM-dd HH:mm:ss";
this.LogTimeEnd.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.LogTimeEnd.Location = new System.Drawing.Point(296, 15);
this.LogTimeEnd.Name = "LogTimeEnd";
this.LogTimeEnd.Size = new System.Drawing.Size(158, 21);
this.LogTimeEnd.TabIndex = 15;


第一个是begin 第二个是end

这是运行以后。。。。我选择狗带
...全文
441 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
星空蔚蓝 2017-05-24
  • 打赏
  • 举报
回复
不知道你的代码具体实现情况,是不是有可能有其他地方又对格式进行了设置呢?
IsaacV_ 2017-05-24
  • 打赏
  • 举报
回复
引用 8 楼 ranshouxu 的回复:
不知道你的代码具体实现情况,是不是有可能有其他地方又对格式进行了设置呢?




这个是查找整个文档的结果,没有地方给他重新赋值呀
IsaacV_ 2017-05-23
  • 打赏
  • 举报
回复
DateTimeCustomFormat是您自己定义的枚举类型吗
IsaacV_ 2017-05-23
  • 打赏
  • 举报
回复
引用 3 楼 ranshouxu 的回复:
/// <summary> /// 设置时间格式为空 /// </summary> /// <param name="dateTimePicker">DateTimePicker控件对象</param> /// <param name="format">使用的时间格式</param> public static void DateTimeIsNull(DateTimePicker dateTimePicker, DateTimeCustomFormat format) { dateTimePicker.Format = DateTimePickerFormat.Custom; dateTimePicker.ResetText(); dateTimePicker.CustomFormat = " "; dateTimePicker.ValueChanged += (s, e) => { DateTimePicker dtp = s as DateTimePicker; if (dtp != null) { switch (format) { case DateTimeCustomFormat.Long: dtp.CustomFormat = "yyyy/MM/dd HH:mm:ss"; break; case DateTimeCustomFormat.Short: dtp.CustomFormat = "yyyy/MM/dd"; break; case DateTimeCustomFormat.NoSecond: dtp.CustomFormat = "yyyy/MM/dd HH:mm"; break; default: break; } } }; 试试这个 不知道适不适合你的要求
DateTimeCustomFormat是个什么类
IsaacV_ 2017-05-23
  • 打赏
  • 举报
回复
引用 6 楼 ranshouxu 的回复:

/// <summary>
/// 用户自定义时间格式
/// </summary>
public enum DateTimeCustomFormat
{
/// <summary>
/// 长类型时间格式 yyyy/MM/dd HH:mm:ss
/// </summary>
Long = 0,
/// <summary>
/// 短类型时间格式 yyyy/MM/dd
/// </summary>
Short = 1,
/// <summary>
/// 没有"秒"时间格式 yyyy/MM/dd HH:MM
/// </summary>
NoSecond = 2
}


效果图23333

算了 这个工程真的有毒,代码我新建工程试过了,没问题

请问有方法比较方便的转移工程的代码吗,我想新建个工程算了
星空蔚蓝 2017-05-23
  • 打赏
  • 举报
回复

/// <summary>
    /// 用户自定义时间格式
    /// </summary>
    public enum DateTimeCustomFormat
    {
        /// <summary>
        /// 长类型时间格式 yyyy/MM/dd HH:mm:ss
        /// </summary>
        Long = 0,
        /// <summary>
        /// 短类型时间格式 yyyy/MM/dd
        /// </summary>
        Short = 1,
        /// <summary>
        /// 没有"秒"时间格式 yyyy/MM/dd HH:MM
        /// </summary>
        NoSecond = 2
    }
IsaacV_ 2017-05-22
  • 打赏
  • 举报
回复


debug得到的值是没问题的

 private void TimeQuest_Load(object sender, EventArgs e)
{
init();
}

private void init()
{
DateTime dtNow = DateTime.Now;
this.LogTimeBegin.Checked = true;
this.LogTimeBegin.Value = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, dtNow.Hour, 0, 0);
this.LogTimeBegin.Checked = false;
this.LogTimeEnd.Checked = true;
this.LogTimeEnd.Value = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, dtNow.Hour, 59, 59);
this.LogTimeEnd.Checked = false;
this.cardId.Text = "";
this.carId.Text = "";
this.expId.Text = "";
this.checkBox1.Checked = false;

System.Diagnostics.Debug.WriteLine(this.LogTimeBegin.Value);
System.Diagnostics.Debug.WriteLine(this.LogTimeEnd.Value);
}
星空蔚蓝 2017-05-22
  • 打赏
  • 举报
回复
/// <summary> /// 设置时间格式为空 /// </summary> /// <param name="dateTimePicker">DateTimePicker控件对象</param> /// <param name="format">使用的时间格式</param> public static void DateTimeIsNull(DateTimePicker dateTimePicker, DateTimeCustomFormat format) { dateTimePicker.Format = DateTimePickerFormat.Custom; dateTimePicker.ResetText(); dateTimePicker.CustomFormat = " "; dateTimePicker.ValueChanged += (s, e) => { DateTimePicker dtp = s as DateTimePicker; if (dtp != null) { switch (format) { case DateTimeCustomFormat.Long: dtp.CustomFormat = "yyyy/MM/dd HH:mm:ss"; break; case DateTimeCustomFormat.Short: dtp.CustomFormat = "yyyy/MM/dd"; break; case DateTimeCustomFormat.NoSecond: dtp.CustomFormat = "yyyy/MM/dd HH:mm"; break; default: break; } } }; 试试这个 不知道适不适合你的要求
IsaacV_ 2017-05-22
  • 打赏
  • 举报
回复


改下字体能稍微正常的显示,但是还是不全0.0,醉了

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧