How to close a StiPreviewControl using ESC Key?

Stimulsoft Reports.NET discussion
Post Reply
Ajax
Posts: 26
Joined: Wed Mar 12, 2008 11:41 pm

How to close a StiPreviewControl using ESC Key?

Post by Ajax »

Can you please tell me how to enable the StiPreviewControl to close if I press the escape key (ESC).

I also would like to know how the config.CloseEnabled works (example

I do

#region ToolBar

//Do this operation once when running the program
StiConfig.Load();
//Get service
StiPreviewConfigService config =
StiConfig.Services.GetService(typeof (StiPreviewConfigService)) as StiPreviewConfigService;
//Turn off all buttons of changes of the rendered report
// config.PageNewEnabled = false;
if (config != null) {
config.CloseEnabled = true;
config.ToolEditorActive = false;
config.ToolEditorEnabled = false;
config.PageDesignEnabled = false;
config.PageDeleteEnabled = false;
config.PageNewEnabled = false;
config.PageSizeEnabled = false;
config.OpenEnabled = false;
config.SaveEnabled = true;
}
//Save configuration if necessary
StiConfig.Save();

#endregion

The close button appears but when I click nothing happens

Thanks in advance.
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

How to close a StiPreviewControl using ESC Key?

Post by Vital »

Hello,
Can you please tell me how to enable the StiPreviewControl to close if I press the escape key (ESC).
Please set KeyPreview property of form which contain StiPreviewControl to true. After then use following code for KeyDown event of form:

Code: Select all

private void StiViewerForm_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Escape)Close();
		}
I also would like to know how the config.CloseEnabled works (example
You need use Close event of StiPreviewControl. Please see example:

Code: Select all

private void ViewerControl_Close(object sender, System.EventArgs e)
		{
			Close();
		}

Thank you.
Ajax
Posts: 26
Joined: Wed Mar 12, 2008 11:41 pm

How to close a StiPreviewControl using ESC Key?

Post by Ajax »

Thanks for the info!
Post Reply