Цветовое форматирование не применяется к моему столбцу XtraTreeList в dev express во время предварительного просмотра - PullRequest
0 голосов
/ 09 апреля 2020

При нажатии Print prieview:

private void PrintPreview_Click(object sender, EventArgs e)
{
    // Adding treeList Component and it's look and feel.
    PreviewPrintableComponent(treeList, treeList.LookAndFeel);
}

Код, отвечающий за предварительный просмотр печати:

void PreviewPrintableComponent(IPrintable component, UserLookAndFeel lookAndFeel)
{
    // Create a link that will print a control. 
    PrintableComponentLink link = new PrintableComponentLink()
    {
        PrintingSystemBase = new PrintingSystemBase(),
        Component = component,
        Landscape = true,
        PaperKind = PaperKind.A5,
        Margins = new Margins(20, 20, 20, 20)
    };

    // I believe somewhere here I need to do something about formatting in 
    // 'component' and 'lookAndFeel'. 


    // creating preview doc
    link.CreateDocument();

    // showing preview
    link.ShowRibbonPreview(lookAndFeel);
}

Код для форматирования моего TreeList. Этот код запускается во время компиляции, поскольку это событие генерируется во время разработки:

private void TreeList_NodeCellStyle(object sender, GetCustomNodeCellStyleEventArgs e)
{
    // "Number" is name of column in which color formatting is applied
    if (e.Column.FieldName == "Number")
    {
        // Changing color to red for negative value.
        if (Convert.ToInt32(e.Node.GetValue(e.Column.AbsoluteIndex)) < 0)
        {
            e.Appearance.ForeColor = Color.Red;
        }
    }
}

My TreeList in FormMy TreeList at print preview

1 Ответ

1 голос
/ 09 апреля 2020

Попробуйте установить свойство TreeListOptionsPrint.UsePrintStyles в false , чтобы использовать внешний вид, указанный в событии NodeCellStyle.

...