简体   繁体   English

GridDataView的C#自定义布局

[英]c# custom layout for GridDataView

Here my question: How can I make a custom layout for a DataGridView in C# ? 这是我的问题:如何在C#中为DataGridView定制布局?

I try to work with the object DataGridView and I think it's the best for making what i want but I can't find how I can merge 2 cells or more from one column. 我尝试使用对象DataGridView,我认为这是实现我想要的最好的方法,但是我找不到如何从一个列合并2个或更多单元格的方法。 I'm sure that is already exist but I can't find something on the web. 我敢肯定那已经存在,但是我在网上找不到东西。 What I want, is a excel like grid 我想要的是像网格一样的Excel

Here a example of what I want to make. 这是我想做的一个例子。

Example of array: 数组示例:

Group = 
[
    Cell 1, [Cell 1, Cell 2],
    Cell 2, [Cell 1, Cell 2, Cell 3],
    Cell 3, []
];

Example of what I want to do : 我想做的例子:
图片范例

I think it's better to use a custom grid control. 我认为最好使用自定义网格控件。 Or you may want to use the XL sheet control of devexpress which is not free. 或者,您可能想使用不是免费的devexpress的XL表控件。 Another option is to use EPPlus → ( http://epplus.codeplex.com ). 另一种选择是使用EPPlus→( http://epplus.codeplex.com )。

The only way I know of to accomplish this is by either one of the following options: 我知道实现此目标的唯一方法是使用以下任一选项:

  1. A third-party control which has cell merging built in. I do not have personal recommendations on this. 具有内置单元合并功能的第三方控件。对此,我没有个人建议。
  2. Handling the CellPaint events properly. 正确处理CellPaint事件。 I've personally done this in projects where I need basic cell merging capabilities. 我亲自在需要基本单元合并功能的项目中完成了此操作。
  3. Find another way to report the data, such as exporting to Excel which does support merging cells. 寻找另一种报告数据的方法,例如导出到支持合并单元格的Excel。

There is no built-in method of performing a merge-cells option in a WinForms DataGridView. WinForms DataGridView中没有执行合并单元格选项的内置方法。

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

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