Change the ICon of tool

Stimulsoft Reports.NET discussion
Post Reply
satisht
Posts: 150
Joined: Mon Apr 09, 2007 12:28 am
Location: Pune

Change the ICon of tool

Post by satisht »

How should i change the icon of export to save icon from tool bar?
Guest
Posts: 182
Joined: Tue Jun 06, 2006 8:04 am

Change the ICon of tool

Post by Guest »

If you want to change behavior of export button, please, see this topic:
http://www.forum.stimulsoft.com/Default ... osts&t=547
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Change the ICon of tool

Post by Vital »

You can access to toolbar via property Toolbar of StiPreviewControl. Control with index 3 is export button.

Thank you.
satisht
Posts: 150
Joined: Mon Apr 09, 2007 12:28 am
Location: Pune

Change the ICon of tool

Post by satisht »

That is readonly property but how should i change the 'ICON' of export button from toolbar in preview window?
Can you provide me code to do this?
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Change the ICon of tool

Post by Edward »

Please use the following code:

Code: Select all

С#:
StiPreviewControl stiPreview = new StiPreviewControl();
StiToolBar tb = stiPreview.ToolBar;
StiToolButton btnSave = (tb.Controls["tbSave"] as StiToolButton);
StiToolButton btnExport = (tb.Controls["tbExport"] as StiToolButton);
btnExport.Image = btnSave.Image;

Code: Select all

VB:
Dim stiPreview As New StiPreviewControl
Dim tb As StiToolBar = stiPreview.ToolBar
Dim btnSave As StiToolButton = TryCast(tb.Controls.get_Item("tbSave"),StiToolButton)
Dim btnExport As StiToolButton = TryCast(tb.Controls.get_Item("tbExport"),StiToolButton)
btnExport.Image = btnSave.Image
The code above you should use when you are using StiPreviewControl on your form for the previewing of the report.
But if you do not using the StiPreviewControl component then you should modify method of calling the report in the following way:

Instead of calling report.Show() (or Show(true)) you should call the method CustomPreview

Code: Select all

C#:
private void CustomPreview()
{
            StiReport report = new StiReport();

            ...

            using (StiPreviewForm form = new StiPreviewForm(report))
            {
                StiPreviewControl stiPreview = form.PreviewControl;
                stiPreview.Close += new EventHandler(stiPreview_Close);
                StiToolBar tb = stiPreview.ToolBar;
                StiToolButton btnSave = (tb.Controls["tbSave"] as StiToolButton);
                StiToolButton btnExport = (tb.Controls["tbExport"] as StiToolButton);
                btnSave.Image = btnExport.Image;
                report.Render();
                form.ShowDialog();
                stiPreview.Close -= new EventHandler(stiPreview_Close);
            }
}

public void stiPreview_Close(object sender, EventArgs e)
{
            ((sender as StiPreviewControl).Parent as StiPreviewForm).Close();
}

Code: Select all

VB:
Private Sub CustomPreview()
    Dim report As New StiReport

    ... 

    Using form As StiPreviewForm = New StiPreviewForm(report)
        Dim stiPreview As StiPreviewControl = form.PreviewControl
        AddHandler stiPreview.Close, New EventHandler(AddressOf Me.stiPreview_Close)
        Dim tb As StiToolBar = stiPreview.ToolBar
        Dim btnSave As StiToolButton = TryCast(tb.Controls.get_Item("tbSave"),StiToolButton)
        Dim btnExport As StiToolButton = TryCast(tb.Controls.get_Item("tbExport"),StiToolButton)
        btnSave.Image = btnExport.Image
        report.Render
        form.ShowDialog
        RemoveHandler stiPreview.Close, New EventHandler(AddressOf Me.stiPreview_Close)
    End Using
End Sub

Public Sub stiPreview_Close(ByVal sender As Object, ByVal e As EventArgs)
    TryCast(TryCast(sender,StiPreviewControl).Parent,Form).Close
End Sub
Thank you.
satisht
Posts: 150
Joined: Mon Apr 09, 2007 12:28 am
Location: Pune

Change the ICon of tool

Post by satisht »

Thank You it works...
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Change the ICon of tool

Post by Edward »

Let us know if you need any help.

Thank you.
Post Reply