我有一个来自DataGridView的Control 派生。我想在运行时在列的标题上方放置一些其他控件。
换句话说,我希望能够拥有
(此处还有其他一些控件) | |||
Id | 姓名 | 年龄 | 薪水 |
1 | Gates | 20 | 100 |
2 | Balmer | 30 | 150 |
而不是¥b $ b
Id | 名称 | 年龄 | 薪水 |
1 | Gates | 20 | 100 |
2 | Balmer | 30 | 150 |
这可能吗?我找不到任何合适的方法来覆盖。
我应该使用包含而不是继承 - 这没有问题:我只需要编写两个嵌套控件的UserControl - 黄色区域的一些容器以及它下面的DataGridView。但正如我在开始时说的,我' m使用 继承 。
解决方案
嗨Comanche, 在我看来,创建一个UserControl是一个更好的选择。 首先,在Visual Studio中创建一个UserControl。 /> 其次,将SplitContainer拖到UserControl,然后将Orientation属性设置为Horizontal。 第三步,将DataGridView或自定义DataGridView拖到panel2中,然后将Dock设置为Fill 。 第四,将一些控件拖到panel1中你和c并添加一些其他面板来控制布局。 如果有任何不清楚的地方,请告诉我。
最好的问候,
Hi,
I have a Control derived from DataGridView. I want to place some other controls above the columns' headers in run time.
In other words, I want to be able to have
(some other controls here) |
|||
Id |
Name |
Age |
Salary |
1 |
Gates |
20 |
100 |
2 |
Balmer |
30 |
150 |
instead of
Id |
Name |
Age |
Salary |
1 |
Gates |
20 |
100 |
2 |
Balmer |
30 |
150 |
Is this possible? I couldn't find any suitable method to override.
Should I use inclusion instead of inheritance - this would be no problem: I would just compose my UserControl of two nested controls - some container for the yellow area plus DataGridView below it.But as I said in the beginning, I'm using inheritance.
解决方案Hi Comanche, In my opinion, creating a UserControl is a better choice. First, create a UserControl in the Visual studio. Second, drag a SplitContainer to the UserControl and then set the Orientation property to Horizontal. Third, drag the DataGridView or your custom DataGridView into the panel2 and then set the Dock to Fill. Fourth, drag some controls into the panel1 and you can also add some other panel to control the layout. If there is anything unclear, please let me know.
Best Regards,
更多推荐
DataGridView后代:在其他控件的列标题上方占用空格?
发布评论