以时间格式使用的MaskedTextBox [英] MaskedTextBox to be used in Time Format

查看:111
本文介绍了以时间格式使用的MaskedTextBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

一个简单的问题.

情况是我需要在运行时更改时间.我无法使用DateTimePicker,因为我需要使用CustomFormat"hh:mm tt".因此,无法使用DateTimePicker更改运行时间.

我进行了一些研究,并在论坛中发现他们建议使用MaskedTextBox.
我对使用它不是很熟悉.

你们能帮我解释一下如何在TimeFormat中使用MaskedTextBox.现在,无论"hh:mm:ss"还是任何我能看到MaskedTextBox起作用的东西都没关系.

谢谢,
Skunkhead:)

Hi guys,

A simple question.

The situation is that I need to change the time during run-time. I cant use DateTimePicker as I need to use CustomFormat "hh:mm tt". So, using DateTimePicker to change the time on run-time is not possible.

I do some research and found in forums they suggest to use MaskedTextBox.
I''m not very familiar to use it.

Can you guys help me to explain how to use the MaskedTextBox in TimeFormat. For now it does not a matter whether "hh:mm:ss" or whatever as long I''m able to see the MaskedTextBox works.

Thanks,
Skunkhead :)

推荐答案

您可以使用DateTimePicker代替所需的位来代替MaskedTextBox:

1)将CustomFormat 属性设置为"hh:mm tt"
2)将Format 属性设置为Custom(如果使用代码而不是设计器,则设置为DateTimePickerFormat.Custom)
3)将ShowUpDown 属性设置为true.

现在,它以您想要的格式显示时间,并且仅显示时间.
Instead of a MaskedTextBox, you can use a DateTimePicker with just the bits you want:

1) Set the CustomFormat property to "hh:mm tt"
2) Set the Format property to Custom (or DateTimePickerFormat.Custom if in code rather than designer)
3) Set the ShowUpDown property to true.

It now shows the time in the format you want, and only the time.


这篇关于以时间格式使用的MaskedTextBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆