简体   繁体   中英

How to use CSS for formatting Crystal Report in Winform?

I am using VS 2008 for a Winform. I have crystal reports in the project which I would like to format with the help of CSS.

Can anyone point me with the right tutorial to start this?

Crystal Reports for Visual Studio has limited HTML formatting. see This Forum Post (Google for more ). I've been recently trying to make some formatting on my reports using HTML and saddly discovered that it doesn't even suport divs it is just for text formatting, and most CSS attributes are not supported. At the end I had to use RTF formatting (Just because I needed the Justify Paragraph option for Legal Letters).

Hope it help,

CSS works only in web application. If you want to customize your windows app look and feel, you can use either XML file or resource file. Specify all of your control's settings into XML or res file and use this file at runtime when your window app form loads.

sample xml

<?xml version="1.0" encoding="utf-8" ?>
<StylesSheetFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                 xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <Styles>
        <Style Name="FormType1">
            <Properties>
                <Property Name="BackColor" Value="White" />
                <Property Name="Text" Value="Personal information" />
                <Property Name="Enabled" Value="true" />
            </Properties>
        </Style>
        <Style Name="DataGridType1">
            <Properties>
                <Property Name="RowsDefaultCellStyle.BackColor" 
                          Value="White" />
                <Property Name="AlternatingRowsDefaultCellStyle.BackColor" 
                          Value="214,222,247" />
                <Property Name="Columns[0].HeaderText" 
                          Value="Color name" />
                <Property Name="Columns[1].HeaderText" Value="My rate" />
            </Properties>
        </Style>
        <Style Name="TabControlType1">
            <Properties>
                <Property Name="Enabled" Value="true" />
                <Property Name="TabPages[0].BackColor" Value="White" />
                <Property Name="TabPages[1].BackColor" Value="White" />
                <Property Name="TabPages[2].BackColor" Value="White" />
            </Properties>
        </Style>
        <Style Name="LabelType1">
            <Properties>
                <Property Name="TextAlign" Value="TopLeft" />
                <Property Name="BorderStyle" Value="None" />
                <Property Name="ForeColor" Value="72,94,158" />
                <Property Name="Font" 
                          Value="Microsoft Sans Serif,8.25pt,style=Regular" />
                <Property Name="Height" Value="20" />
                <Property Name="Enabled" Value="true" />
            </Properties>
        </Style>
        <Style Name="LabelType2">
            <Properties>
                <Property Name="ForeColor" Value="Red" />
                <Property Name="Font" 
                          Value="Microsoft Sans Serif,8.25pt,style=Bold" />
            </Properties>
        </Style>
        <Style Name="TextBoxType1">
            <Properties>
                <Property Name="TextAlign" Value="Left" />
                <Property Name="BorderStyle" Value="Fixed3D" />
                <Property Name="Font" Value="Tahoma,10,style=Regular" />
                <Property Name="Height" Value="20" />
                <Property Name="Width" Value="200" />
                <Property Name="BackColor" Value="214, 222, 247" />
            </Properties>
        </Style>
        <Style Name="HyperLinkType1">
            <Properties>
                <Property Name="BorderStyle" Value="None" />
                <Property Name="ForeColor" Value="Blue" />
                <Property Name="Font" 
                          Value="Tahoma,10,style=Italic,Underline" />
                <Property Name="Height" Value="30" />
                <Property Name="Width" Value="200" />
                <Property Name="Enabled" Value="true" />
            </Properties>
        </Style>
        <Style Name="ButtonType1">
            <Properties>
                <Property Name="TextAlign" Value="TopLeft" />
                <Property Name="ForeColor" Value="Black" />
                <Property Name="BackColor" Value="214;222;247" />
                <Property Name="Font" Value="Tahoma,8.25,style=Italic" />
                <Property Name="Height" Value="23" />
                <Property Name="Enabled" Value="true" />
            </Properties>
        </Style>
        <Style Name="ComboBoxType1">
            <Properties>
                <Property Name="BackColor" Value="White" />
                <Property Name="Font" Value="Tahoma,10,style=Italic" />
                <Property Name="Height" Value="30" />
                <Property Name="Width" Value="200" />
                <Property Name="Enabled" Value="true" />
            </Properties>
        </Style>
        <Style Name="RadioButtonType1">
            <Properties>
                <Property Name="ForeColor" Value="Blue" />
                <Property Name="Font" Value="Verdana,8,style=Regular" />
                <Property Name="Width" Value="150" />
                <Property Name="Enabled" Value="true" />
            </Properties>
        </Style>
    </Styles>
</StylesSheetFile>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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