C# - 如何为datagridview创建输入掩码 [英] C# - how to make an input mask for datagridview

查看:88
本文介绍了C# - 如何为datagridview创建输入掩码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

向所有人致意,



我是初学程序员使用C#.Net在Visual Studio 2015中开发一个小型WinForms应用程序并需要一个日期输入掩码(不是格式化) )对于在DataGridView的第一列中输入的数字。我该怎么做呢?我真的很感激一些示例代码。非常感谢您的所有时间和帮助。



祝你好运,



我尝试了什么:



我没有尝试任何代码,因为我甚至不知道如何开始!

Greetings to all,

I'm beginner programmer developing a small WinForms application in Visual Studio 2015 using C# .Net and need a date input mask (not format) for the numbers entered in the first column of a DataGridView. How do I go about doing that? I'd really appreciate some sample code. Thank you very much for your all your time and help.

Best regards,

What I have tried:

I haven't tried any code because I don't even know how to begin!

推荐答案

作为一个初学者(或者即使没有),在进行数据输入时,有时只需要为年,月和日分别设置列(例如:是yyyymmdd; ddmmyyyy; yyyy -mm-dd;等等。)用户不介意你不要让他们使用更多按键。



数据网格不支持蒙面编辑控件(这是你想要的)。



并且日期不是有效之前的日期;所以忘记格式化,并在准备保存时验证日期列;然后结合起来制作一个日期进行存储。再次编辑时再次拆分它。
As a "beginner" (or even if not), it's sometimes easier just to have separate columns for year, month and day when doing data entry (like: is it yyyymmdd; ddmmyyyy; yyyy-mm-dd; etc. etc.) The "user" won't mind if you don't make them use "more" keystrokes.

The data grid does not support the "masked edit control" (which is what you want).

And a "date" is not a date until it is "valid"; so forget about "formatting", and "validate" the "date columns" when ready to "save"; then combine to make a "date" for storing. "Split" it again, later, when editing again.


这篇关于C# - 如何为datagridview创建输入掩码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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