views:

696

answers:

3

Hi

Is it possible to change the image (the green spinning thing) of the ReportViewer control?

At the moment I am hiding it and overlapping a progress bar (this is WinForms not the ASP Control)... Seems a bit long winded?

Thanks :)

+4  A: 

Well, you gave me a challenge with this one my friend. But I figured out how to do this. Here is the code that I used to pull this off:

 Private Sub CustomizeRV(ByVal ctrl As Control)
    For Each c As Control In ctrl.Controls

      If TypeOf c Is PictureBox Then
        Dim pb As PictureBox = DirectCast(c, PictureBox)
        pb.Image = YOURNEWIMAGEHERE
      End If

      If c.HasChildren Then
        CustomizeRV(c)
      End If
    Next
  End Sub

Call this function during your form load event, and it will reconfigure the loading image to whatever you specify (pass the function the ReportViewer control). The function is called recursively until the picturebox is found. There is only one picturebox in the ReportViewer control, so you don't have to worry about finding that specific one.

Jon
Brilliant! Worked great. I have converted your code to C# for the project this is for (ill include it as an answer so it can be formatted) - but thanks! I dont see why they never had this as an option in the first place?
Chalkey
+2  A: 

Thanks again to Jon for the original VB.NET code... Here is his answer in C#...

private void CustomizeReportViewer(Control reportViewer)
{
    foreach (Control c in reportViewer.Controls)
    {
        if (c.GetType() == typeof(PictureBox))
        {
            (c as PictureBox).ImageLocation = "C:\\Loading.gif";
            return;
        }

        if (c.HasChildren)
            CustomizeReportViewer(c);
    }
}
Chalkey
A: 

this is on the winform, what about web form?

Irman