gpt4 book ai didi

c# - 自定义单元格合并

转载 作者:行者123 更新时间:2023-11-30 16:40:33 26 4
gpt4 key购买 nike

我需要在 gridview 中显示某些列的合并行的数据。来自数据库的原始数据,如:

enter image description here

请帮我显示 gridview,如:

enter image description here

  • 对于 transaksi 列由 tgl 合并
  • 对于 priority 列,price创建者transaksi 合并

使用 C#,如何为格式准备 gridview?请帮助我。

最佳答案

我建议您查看文档 - Tutorial: Cell Merging

To implement custom cell merge use the GridView.CellMerge event handler. First, check if the correct column is being processed. Then, obtain display texts for the two cells being compared. Finally, indicate that cells are to be merged if their display texts match. Set the CellMergeEventArgs.Handled parameter to true to override the grid's default processing for this column.

示例:

using DevExpress.XtraGrid.Views.Grid;
// ...
private void gridView1_CellMerge(object sender, DevExpress.XtraGrid.Views.Grid.CellMergeEventArgs e) {
GridView view = sender as GridView;
if(view == null) return;
if (e.Column == colCreatorID) {
string text1 = view.GetRowCellDisplayText(e.RowHandle1, colCreatorID);
string text2 = view.GetRowCellDisplayText(e.RowHandle2, colCreatorID);
e.Merge = (text1 == text2);
e.Handled = true;
}
}

在处理列时使用您自己的条件。例如采用 transaksi 005,在这种情况下,检查第 5 行和第 6 行的值,然后比较由创建的列是否相等取决于您的条件,将 e.Merge 设置为 是的

关于c# - 自定义单元格合并,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51148446/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com