问题描述
有没有办法把一个DateTimePicker控制在DataGridView?
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.
推荐答案
您还没有错过任何内置的选项,但可以通过继承两个的DataGridViewColumn
和的DataGridViewCell
班主办您选择的任何控制权。
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上介绍的过程中更多的细节,甚至包括一些示例code:
如何在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
您还可以找到code项目的完整示例:通用的DataGridView V2.0
You can also find a complete sample on Code Project: Generic DataGridView V2.0
这篇关于我怎样才能显示在一个DataGridView一个DateTimePicker?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!