【问题标题】:How to use CSS for formatting Crystal Report in Winform?如何在 Winform 中使用 CSS 格式化 Crystal Report?
【发布时间】:2013-02-28 04:57:56
【问题描述】:

我正在使用 VS 2008 作为 Winform。我在项目中有水晶报告,我想在 CSS 的帮助下对其进行格式化。

谁能指出我正确的教程来开始这个?

【问题讨论】:

    标签: c# css winforms visual-studio-2008 crystal-reports


    【解决方案1】:

    Crystal Reports for Visual Studio 的 HTML 格式有限。见This Forum Post(谷歌more)。 我最近一直在尝试使用 HTML 对我的报告进行一些格式化,但遗憾地发现它甚至不支持 div,它仅用于文本格式,并且大多数 CSS 属性不受支持。最后我不得不使用 RTF 格式(只是因为我需要 Legal Letters 的 Justify Paragraph 选项)。

    希望对你有帮助,

    【讨论】:

      【解决方案2】:

      CSS 仅适用于 Web 应用程序。如果要自定义 Windows 应用程序的外观,可以使用 XML 文件或资源文件。将控件的所有设置指定到 XML 或 res 文件中,并在加载窗口应用程序表单时在运行时使用此文件。

      示例 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>
      

      【讨论】:

      • 我在哪里可以找到 Winforms 中的 .aspx 页面?我希望您阅读问题 It not for WebForms but for Winforms
      • 是的,你不能在 winforms 应用程序中使用 CSS。您可以在应用程序中嵌入浏览器并在其显示的页面上使用 CSS,但不能在实际控件上使用。您可以获得各种库,这些库可以让您控制表单中控件的呈现,然后为它们应用皮肤。请注意,这将增加运行它所需的内存量和处理能力。如果您在 WPF 中工作,那么它会更适合自定义皮肤,因为该技术是内置的。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-13
      相关资源
      最近更新 更多