【问题标题】:Insert Line Break into XtraGrid Cells在 XtraGrid 单元格中插入换行符
【发布时间】:2016-10-26 05:08:21
【问题描述】:

我正在为员工的轮班时间表创建日历视图。

基本上,我需要做的是用换行符替换单元格中的“ - ”,以便单元格显示为:

|--------|
|Saturday|
|--------|
|   1    |
|   O2   |
----------

真诚感谢任何帮助。

【问题讨论】:

    标签: c# winforms devexpress xtragrid


    【解决方案1】:

    您可以使用RepositoryItemMemoEdit 作为您的ColumnEdit。它允许在单元格中使用换行符。
    这是一个例子:

    var edit = new RepositoryItemMemoEdit();
    
    foreach (GridColumn column in gridView1.Columns)
        column.ColumnEdit = edit;
    
    gridView1.SetRowCellValue(1, gridView1.Columns[0], "2\n02");
    

    【讨论】:

    • 非常感谢! :) RepositoryItemMemoEdit() 这是我一直需要的。
    【解决方案2】:

    您可以使用ColumnView.CustomColumnDisplayText 事件,在那里您可以使用'-' 拆分文本或替换为Environment.NewLine

    第二种方法,使用HTML Text Formatting 作为网格编辑器。有关此方法,请参阅 search result

    参考资料:
    Unable to display HTML text in XtraGrid

    【讨论】:

      猜你喜欢
      • 2010-10-18
      • 1970-01-01
      • 1970-01-01
      • 2012-04-11
      • 2013-06-14
      • 1970-01-01
      • 2018-08-08
      • 1970-01-01
      • 2015-03-18
      相关资源
      最近更新 更多