DataGridViewTextBoxCell显示用户控件 [英] DataGridViewTextBoxCell to display usercontrol

查看:195
本文介绍了DataGridViewTextBoxCell显示用户控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用C#开发自定义DatagridViewColumn.
我有一个带有datetime列的datagridviewcolumn.
当显示datagridview时,我希望将单元格显示为用户控件.
用户控件的每个日期组件都有几个文本框(日期为txtbox,月份为txtbox等).
用户控件工作正常.但问题是我想将datagridtextboxcell更改为用户控件
加载数据时.Web上的所有示例都指向initializeeditevent,但是我想要datagridcolumn
在表单展开时(而不是在编辑模式下)显示为用户控件.
我如何通过为此创建自定义datagridviewcolumn控件来做到这一点?

I am using C# to develop a Custom DatagridViewColumn.
I have a datagridviewcolumn which has a datetime column.
When the datagridview is displayed i would like the cell to be displayed as a user control.
The user control has a couple of textboxes for each of the date components(txtbox for day, txtbox for month etc.).
The user control works fine. but the problem is i want to change the datagridtextboxcell to the user control
when loading the data.All the exmaples on the web point to the initializeeditevent but i want the datagridcolumn
to show as a user controlwhen form is loaaded rather than in edit mode.
How can i do this by creating a custom datagridviewcolumn control for this?

推荐答案

而不是使DatagridViewColumn本身成为用户控件.为什么不尝试将单独的DateComponent UserControl注入到DatagridViewColumn中.
您可以很好地将任何控件插入单元格中.
Instead of making DatagridViewColumn itself to usercontrol. Why are you not trying to inject the seperate DateComponent UserControl inside the DatagridViewColumn.
You can very well inject any control inside the cell.


这篇关于DataGridViewTextBoxCell显示用户控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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