简体   繁体   English

在C#Windows应用程序中合并一行数据网格视图的单元格

[英]Merging cells of a row of data grid view in C# windows application

是否可以在C#Windows应用程序中合并数据网格视图特定行的两个或多个单元格?

Quickedy quick Google search turns up this. Quickedy快速Google搜索可以解决这个问题。

http://www.codeguru.com/forum/showthread.php?t=415930 http://www.codeguru.com/forum/showthread.php?t=415930

But no, natively you can't - Datagridviews are not equal to HTML tables or Excel sheets. 但是,不,从本质上讲您不能-Datagridviews不等于HTML表格或Excel工作表。 They simply take the datasource that is bound to them and (after some optional trickery) present the datasource in columns and rows. 他们只是简单地获取绑定到他们的数据源,并且(经过一些可选的技巧之后)将数据源显示为列和行。

You can create your own column class by inheriting the DataGridViewColumn class or any of its derived classes to provide custom appearance, behavior, or hosted controls. 您可以通过继承DataGridViewColumn类或其任何派生类来创建自己的列类,以提供自定义外观,行为或托管控件。 For more information, see Custom Column 有关更多信息,请参见“ 自定义列”

Yes, You will have to use DataTemplate within a TemplatedColumn 是的,您将必须在 TemplatedColumn使用 DataTemplate

\n

and Bind the data to two separate textblocks within the template. 并将数据绑定到模板中的两个单独的文本块。

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

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