RDLC 源代码 如何更改 table 列中的文本颜色

RDLC source code How to i change text color in table column

如何在 RDLC 中设置文本颜色?许多示例显示使用 Microsoft visual basic 更改颜色。但是我如何在没有它的情况下将它添加到我的代码中。我看到很多例子都给出了相同的代码,如下所示

我的条件(值):Textbox4 = 0

=IIF(Fields!Textbox4.Value = 0,"Red","Black"). 

但是我应该把它们放在哪里呢?我试图在样式之间插入但它不起作用。

<TablixCell>
    <CellContents>
        <Textbox Name="Textbox4">
            <CanGrow>true</CanGrow>
            <KeepTogether>true</KeepTogether>
            <Paragraphs>
                <Paragraph>
                    <TextRuns>
                        <TextRun>
                            <Value>Total Work Time</Value>
                            <Style>
                                <FontSize>8pt</FontSize>
                                <FontWeight>Bold</FontWeight>
                            </Style>
                        </TextRun>
                    </TextRuns>
                    <Style>
                        <TextAlign>Left</TextAlign>
                    </Style>
                </Paragraph>
            </Paragraphs>
            <rd:DefaultName>Textbox4</rd:DefaultName>
            <Style>
                <Border>
                    <Color>LightGrey</Color>
                    <Style>Solid</Style>
                </Border>
                <PaddingLeft>2pt</PaddingLeft>
                <PaddingRight>2pt</PaddingRight>
                <PaddingTop>2pt</PaddingTop>
                <PaddingBottom>2pt</PaddingBottom>
            </Style>
        </Textbox>
    </CellContents>
</TablixCell>

转到您需要条件颜色的 tablecell。然后去Placeholder Properties..然后去selectFont然后你可以看到在color dropdown旁边有一个叫Fxbutton。单击按钮并将您的代码放在那里

=IIF(Fields!Textbox4.Value = 0,"Red","Black")

你把它放在 style 标签中是正确的。但是有一些issue.I认为你post代码为headertextbox。您应该在值 textbox 中执行此操作。值 textbox 将包含来自您的 datasetDbColumn 作为值,该字段应如下所示..

<TablixCell>
<CellContents>
    <Textbox Name="Textbox4">
        <CanGrow>true</CanGrow>
        <KeepTogether>true</KeepTogether>
        <Paragraphs>
            <Paragraph>
                <TextRuns>
                    <TextRun>
                        <Value>=Fields!SomeDbColumn.Value</Value>
                        <Style>
                            <Color>=IIF(Fields!SomeDbColumn.Value = 0,"Red","Black")</Color>
                            <FontSize>8pt</FontSize>
                            <FontWeight>Bold</FontWeight>
                        </Style>
                    </TextRun>
                </TextRuns>
                <Style>
                    <TextAlign>Left</TextAlign>
                </Style>
            </Paragraph>
        </Paragraphs>
        <rd:DefaultName>SomeDbColumn</rd:DefaultName>
        <Style>
            <Border>
                <Color>LightGrey</Color>
                <Style>Solid</Style>
            </Border>
            <PaddingLeft>2pt</PaddingLeft>
            <PaddingRight>2pt</PaddingRight>
            <PaddingTop>2pt</PaddingTop>
            <PaddingBottom>2pt</PaddingBottom>
        </Style>
    </Textbox>
</CellContents>