Page 1 of 1

Change the ICon of tool

Posted: Mon May 28, 2007 12:11 am
by satisht
How should i change the icon of export to save icon from tool bar?

Change the ICon of tool

Posted: Mon May 28, 2007 3:29 pm
by Guest
If you want to change behavior of export button, please, see this topic:
http://www.forum.stimulsoft.com/Default ... osts&t=547

Change the ICon of tool

Posted: Mon May 28, 2007 5:40 pm
by Vital
You can access to toolbar via property Toolbar of StiPreviewControl. Control with index 3 is export button.

Thank you.

Change the ICon of tool

Posted: Tue May 29, 2007 6:18 am
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?

Change the ICon of tool

Posted: Tue May 29, 2007 10:07 am
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.

Change the ICon of tool

Posted: Tue May 29, 2007 11:50 pm
by satisht
Thank You it works...

Change the ICon of tool

Posted: Wed May 30, 2007 2:15 am
by Edward
Let us know if you need any help.

Thank you.