简体   繁体   English

是否可以在数据网格视图中合并单元格

[英]Is it Possible to Merge Cells in a datagrid view

is there any way to merge cells in a datagrid view or atleast can we show on the screen like some columns in the grid belongs to one group. 有什么方法可以合并数据网格视图中的单元格,或者至少可以像在网格中的某些列属于一组那样在屏幕上显示。

for example ill take three columns: column1: year field(a drop down type) column2: month field(a drop down type) column3: date field(a drop down type) 例如,请占用三列:column1:年份字段(下拉类型)column2:月份字段(下拉类型)column3:日期字段(下拉类型)

all these three should be grouped to dateofbirth cell. 所有这三个都应归为出生日期单元格。

or is there any way to embed calendar component in the cell.. just like in some sites when we book some tickets we click on calendar icon & click the date and it will be captured in the corresponding field.. 还是有任何方法可以将日历组件嵌入到单元格中。就像在某些网站上预订某些票证时,我们单击日历图标并单击日期,它将被捕获在相应的字段中。

any ideas? 有任何想法吗?

You can create your own DataGridViewCalendarColumn by inheriting from DataGridViewColumn, and a DataGridViewCalendarCell by inheriting from DataGridViewCell or DataGridViewTextBoxCell. 您可以通过从DataGridViewColumn继承来创建自己的DataGridViewCalendarColumn,并通过从DataGridViewCell或DataGridViewTextBoxCell继承来创建DataGridViewCalendarCell。

This isn't something I've done myself, but there are loads of tutorials online explaining how to create custom DataGridView columns. 这不是我自己要做的事情,但是在线上有大量教程介绍了如何创建自定义DataGridView列。 A google search may help. 谷歌搜索可能会有所帮助。

what i have done for this is as follows: 我为此所做的工作如下:

i have taken a date time picker obj,which will be in invisible mode initially. 我已经选择了一个日期时间选择器obj,它最初将处于不可见模式。 when i focus on the date of birth cell ,then date time picker will invoke(in a dialog) and will be visible for this focus time. 当我关注生日单元格的日期时,日期时间选择器将调用(在对话框中)并在此焦点时间可见。 after selecting the date,the value will be inserted into the current cell. 选择日期后,该值将插入到当前单元格中。 if the focus is on the next rows and the corresponding cell then once again we follow the above step. 如果焦点在下一行和相应的单元格上,则再次执行上述步骤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM