Page 1 of 1

How to close a StiPreviewControl using ESC Key?

Posted: Sun Jun 22, 2008 4:32 am
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.

How to close a StiPreviewControl using ESC Key?

Posted: Mon Jun 23, 2008 6:39 am
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.

How to close a StiPreviewControl using ESC Key?

Posted: Tue Jun 24, 2008 12:19 am
by Ajax
Thanks for the info!