Ticket Q413315
Visible to All Users

"Control does not support transparent background colors" when trying to print report

created 13 years ago

We upgraded to 12.1.4 this morning. Blank reports that I create in our project now (or certain reports I pull up from the previous version) come up with a "Control does not support transparent background colors" message at the "ShowPreview" line at run-time. Whether I use this old methodology or the new method using the ReportPrintTool I get the same error.

XtraReport1 rpt = new XtraReport1();
ReportPrintTool tool = new ReportPrintTool(rpt);
tool.PreviewForm.Show();

XtraReport1 rpt2 = new XtraReport1();
rpt.ShowPreview();
rpt2.ShowPreview();

Help! I can view all the reports in the designer. But these reports don't have any controls on them. These reports all worked before. And I can't even add a new report to "recreate" the report. A blank report throws the errors.

I know this has something to do with my project. When I open a new C# project and add the report control I don't run into this. I just need some help trying to find a place I can start looking.

Oh, and I also tried to add the:
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
line to my MDI form and the child form - no success.

Thanks,
Mark

Comments (3)
DevExpress Support Team 13 years ago

    Hi Mark,
    Thank you for your report. This error occurs when the SupportsTransparentBackColor option is disabled and the Transparent background color is assigned to a control (Form). Our attempts to reproduce a similar error were unsuccessful. It looks like a different factor is involved. If possible, describe your application startup procedure in greater detail. We will check for a suitable solution.

    M M
    Mark Gerlach - Shultz 13 years ago

      This is my Program.cs file. From there it loads the main MDI form to the application, which has nothing in it but DevX and Windows .NET Controls. From there, I load a child form and then the report in the form_load event.
      Application.EnableVisualStyles();
      Application.SetCompatibleTextRenderingDefault(false);
      Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
      Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
      Application.Run(new forms.frmMDI());

      M M
      Mark Gerlach - Shultz 13 years ago

        Alright, so I think I've found the problem by narrowing down the loading event code. I have a login form that shows after the main form loads. In that login form, I have the following code:
        layoutLogin.LookAndFeel.UseDefaultLookAndFeel = false;
        layoutLogin.LookAndFeel.UseWindowsXPTheme = true;
        layoutLogin.BackColor = Color.Transparent;
        where layoutLogin is a custom layout control derived from DevExpress.XtraLayout.LayoutControl. When I set the backcolor to transparent on that last line, it affects all other forms in the project. And (I believe) when you run your show preview it's affected by that as well. I'm working on splitting this off right now by using the StyleController and applying it just to that control.
        If you have any pointers for me on how to do this, I'd greatly appreciate it. In the meantime, I'll keep trudging along.
        Thanks,
        Mark

        Answers approved by DevExpress Support

        created 13 years ago (modified 13 years ago)

        Alright, so I think I have the solution. Way back in 2008 or 2009 your layout control had the ability to put in padding/spacing around the outside. The new layout control doesn't have this in its default instance. When you took out this ability, we coded our own "base" class for the layout control. This set us back to normal.

        However, in my code I was setting the default look and feel to something different, and it was affecting every form in the application. Apparently your reporting preview doesn't like it when some of the skin options have a back color = transparent. So it was throwing this error. You may want to look into this. I've posted my code below so you can see what I'm doing.

        When I created a new "base" version of this class and took out the transparency code, it works just fine in the latest instance.

        DevExpress.Skins.Skin currentSkin = null;
                       DevExpress.Skins.Skin tabSkin = null;
                       DevExpress.Skins.Skin navBarSkin = null;
                       DevExpress.Skins.Skin formSkin = null;

        DevExpress.Skins.SkinElement elementForm, elementPanel, elementPanelNoBorder, layoutItem;
                       DevExpress.Skins.SkinElement panelBottom, panelTop, panelLeft, panelRight;
                       DevExpress.Skins.SkinElement layoutItemPadding, layoutGroupPadding, layoutRootGroupPadding;
                       DevExpress.Skins.SkinElement layoutGroupWithoutBordersPadding, layoutRootGroupWithoutBordersPadding;

        DevExpress.LookAndFeel.DefaultLookAndFeel df = new DevExpress.LookAndFeel.DefaultLookAndFeel();
                       df.LookAndFeel.SkinName = "Black";
                       currentSkin = DevExpress.Skins.CommonSkins.GetSkin(df.LookAndFeel);
                       tabSkin = DevExpress.Skins.TabSkins.GetSkin(df.LookAndFeel);
                       navBarSkin = DevExpress.Skins.NavBarSkins.GetSkin(df.LookAndFeel);
                       formSkin = DevExpress.Skins.FormSkins.GetSkin(df.LookAndFeel);

        elementForm = currentSkin[DevExpress.Skins.CommonSkins.SkinForm];
                       elementPanel = currentSkin[DevExpress.Skins.CommonSkins.SkinGroupPanel];
                       elementPanelNoBorder = currentSkin[DevExpress.Skins.CommonSkins.SkinGroupPanelNoBorder];
                       layoutItem = currentSkin[DevExpress.Skins.CommonSkins.SkinLayoutItemBackground];
                       panelBottom = currentSkin[DevExpress.Skins.CommonSkins.SkinGroupPanelBottom];
                       panelTop = currentSkin[DevExpress.Skins.CommonSkins.SkinGroupPanelTop];
                       panelLeft = currentSkin[DevExpress.Skins.CommonSkins.SkinGroupPanelLeft];
                       panelRight = currentSkin[DevExpress.Skins.CommonSkins.SkinGroupPanelRight];

        layoutItemPadding = currentSkin[DevExpress.Skins.CommonSkins.SkinLayoutItemPadding];
                       layoutGroupPadding = currentSkin[DevExpress.Skins.CommonSkins.SkinLayoutGroupPadding];
                       layoutRootGroupPadding = currentSkin[DevExpress.Skins.CommonSkins.SkinLayoutRootGroupPadding];
                       layoutGroupWithoutBordersPadding = currentSkin[DevExpress.Skins.CommonSkins.SkinLayoutGroupWithoutBordersPadding];
                       layoutRootGroupWithoutBordersPadding = currentSkin[DevExpress.Skins.CommonSkins.SkinLayoutRootGroupWithoutBordersPadding];

        if (elementPanel.Image.Image != null)
                       {
                            elementPanel.Image.Image = null;
                       }

        DevExpress.Skins.SkinElement element;
                       element = tabSkin[DevExpress.Skins.TabSkins.SkinTabPane];

        DevExpress.Skins.SkinElement navbar = navBarSkin[DevExpress.Skins.NavBarSkins.SkinBackground];

        layoutItem.Color.BackColor =
                            elementForm.Color.BackColor =
                            elementPanel.Color.BackColor =
                            elementPanelNoBorder.Color.BackColor =
                            panelBottom.Color.SolidImageCenterColor =
                            panelTop.Color.SolidImageCenterColor =
                            panelLeft.Color.SolidImageCenterColor =
                            panelRight.Color.SolidImageCenterColor =
                            element.Color.SolidImageCenterColor =
                            navbar.Color.BackColor =
                            base.BackColor;

        if (elementPanel.Image.Image != null)
                       {
                            elementPanel.Image.Image = null;
                       }

          Comments (1)
          DevExpress Support Team 13 years ago

            Thank you for providing a workaround. I believe that it will be useful for other users who will face the same issue.

            Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

            Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.