We help IT Professionals succeed at work.

Report Viewer Control - Toolbar Font Colour

dwhitfield_CPWN
on
Hi,

I cant seem to find a property to set the font colour of the report viewer toolbar.

I have managed to set the background colour using backcolor.

If there isn't a property is there any other way of setting the font colour?
Comment
Watch Question

Commented:
Is this the crystal report viewer control or the Microsoft Report viewer control?
Top Expert 2010

Commented:

You can try the following:

ToolStrip toolStrip = (ToolStrip)reportViewer.Controls.Find("toolStrip1", true)[0];

toolStrip.ForeColor = Color.Blue;

Note that this is untested and this link discusses about ways like this to modify the toolbar => http://stackoverflow.com/questions/114733/reportviewer-modify-toolbar

Author

Commented:
Its for the Microsoft Report viewer control.

kris_per solution looks good but I need a similar solution for ASP.NET?
Top Expert 2010

Commented:

I just tried the below code. this sets a color to all the inner controls of ToolBarControl control of ReportViewer....Hope this might help you in some way....

protected void Page_Load(object sender, EventArgs e)
        {
            // ReportViewer1.Controls[1] is the ToolBarControl

            WebControl control = ReportViewer1.Controls[1] as WebControl;

            SetColorToAllChildControls(control);
         }

private void SetColorToAllChildControls(Control control)
        {
            if (control is WebControl)
                (control as WebControl).ForeColor = System.Drawing.Color.DeepPink;

            foreach (Control c in control.Controls)
            {
                SetColorToAllChildControls(c);
            }
        }


Author

Commented:
Hi,

it sets the majority of the controls as deep pink but not the export and find/next labels (see attached image)?

I would have thought that these would have been label controls?
toolbar.jpg
Top Expert 2010
Commented:

The Find/Export controls looks like Links and I tried setting the LinkActiveColor/LinkDisabledColor properties of the ReportViewer in the designer and it changes the color of Find/Export controls...But this might affect the links in the actual report as well...

These Find/Export controls are TextButton controls which are internal to Microsoft.Reporting.WebForms namespace and I cant find any Link color property for these controls. I am not sure if using the SkinID property of these controls to a skin file might help, if a skin can include link color settings (i m not much familiar with using skins for controls)


protected void Page_Load(object sender, EventArgs e)
        {
          // These link colors can also be set in ReportViewer designer
          // Setting link colors changes the forecolor of Find/Export text in the toolbar

            ReportViewer1.LinkActiveColor = System.Drawing.Color.DeepPink;
            ReportViewer1.LinkActiveHoverColor = System.Drawing.Color.DeepPink;
            ReportViewer1.LinkDisabledColor = System.Drawing.Color.DeepPink;

            WebControl control = ReportViewer1.Controls[1] as WebControl;
            SetColorToAllChildControls(control);
        }

Hope this helps...