如何在 DataGridView 中显示 DateTimePicker? [英] How can I display a DateTimePicker in a DataGridView?

查看:51
本文介绍了如何在 DataGridView 中显示 DateTimePicker?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么办法可以在DataGridView中放置一个DateTimePicker控件?

Is there any way to put a DateTimePicker control in the DataGridView?

我检查了所有可能的属性,但它提供了复选框、组合框等选项,但没有提供 DateTimePicker.

I checked all the possible properties but it give option of checkbox, combo box etc, but not the DateTimePicker.

推荐答案

您没有错过任何内置选项,但是可以将 DataGridViewColumnDataGridViewCell<子类化/code> 类来托管您选择的任何控件.

You haven't missed any built-in option, but it is possible to subclass both the DataGridViewColumn and DataGridViewCell classes to host any control of your choosing.

MSDN上的这篇文章更详细地解释了这个过程,甚至包括一些示例代码:
如何:在 Windows 窗体 DataGridView 单元格中托管控件

This article on MSDN explains the process in more detail, and even includes some sample code:
How to: Host Controls in Windows Forms DataGridView Cells

您还可以在代码项目中找到完整示例:Generic DataGridView V2.0

You can also find a complete sample on Code Project: Generic DataGridView V2.0

这篇关于如何在 DataGridView 中显示 DateTimePicker?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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