Occurs when the report designer is about to show the "Open" dialog.
Use this event to attach own "Open" dialog to the designer. In the event handler, you must
display a dialog window to allow user to choose a report file.
If dialog was executed successfully, you must return e.Cancel = false and set the
e.FileName to the selected file name.
You also need to use event to provide code that
will open the report.
Occurs when the report designer is about to show the "Save" dialog.
Use this event to attach own "Save" dialog to the designer. In the event handler, you must
display a dialog window to allow user to choose a report file.
If dialog was executed successfully, you must return e.Cancel = false and set the
e.FileName to the selected file name.
You also need to use event to provide code that
will save the report.
Occurs when the report designer is about to load the report.
This event is used together with the event.
Use this event to attach own "Open" dialog to the designer. In the event handler, you must
load the e.Report from the location specified in the e.FileName property.
For example, if you work with files: e.Report.Load(e.FileName);
Occurs when the report designer is about to save the report.
This event is used together with the event.
Use this event to attach own "Save" dialog to the designer. In the event handler, you must
save the e.Report to the location specified in the e.FileName property.
For example, if you work with files: e.Report.Save(e.FileName);
Occurs when database connection is about to open.
Use this event to provide own connection string or user name/password to the connection
object that is about to open.
To provide own connection string, set the e.ConnectionString property.
In this case the new connection string will be used.
To provide own user name/password, set the e.UserName and e.Password properties.
You may ask these values in own login dialog.
This example shows how to provide username/password using own login dialog.
private void report1_DatabaseLogin(object sender, DatabaseLoginEventArgs e)
{
using (MyLoginDialog dialog = new MyLoginDialog())
{
if (dialog.ShowDialog() == DialogResult.OK)
{
e.UserName = dialog.UserName;
e.Password = dialog.Password;
}
}
}
This example shows how to provide own connection string.
private void report1_DatabaseLogin(object sender, DatabaseLoginEventArgs e)
{
e.ConnectionString = my_connection_string;
}
This example shows how to attach own "Open" and "Save" dialogs to the designer.
It uses the following events: , ,
, .
private void CustomOpenDialog_Handler(object sender, OpenSaveDialogEventArgs e)
{
using (OpenFileDialog dialog = new OpenFileDialog())
{
dialog.Filter = "Report files (*.frx)|*.frx";
// set e.Cancel to false if dialog was succesfully executed
e.Cancel = dialog.ShowDialog() != DialogResult.OK;
// set e.FileName to the selected file name
e.FileName = dialog.FileName;
}
}
private void CustomSaveDialog_Handler(object sender, OpenSaveDialogEventArgs e)
{
using (SaveFileDialog dialog = new SaveFileDialog())
{
dialog.Filter = "Report files (*.frx)|*.frx";
// get default file name from e.FileName
dialog.FileName = e.FileName;
// set e.Cancel to false if dialog was succesfully executed
e.Cancel = dialog.ShowDialog() != DialogResult.OK;
// set e.FileName to the selected file name
e.FileName = dialog.FileName;
}
}
private void CustomOpenReport_Handler(object sender, OpenSaveReportEventArgs e)
{
// load the report from the given e.FileName
e.Report.Load(e.FileName);
}
private void CustomSaveReport_Handler(object sender, OpenSaveReportEventArgs e)
{
// save the report to the given e.FileName
e.Report.Save(e.FileName);
}