Canceling a forms OK button

Stimulsoft Reports.NET discussion
Jennypi
Posts: 361
Joined: Mon Nov 17, 2008 7:13 am
Location: France

Re: Canceling a forms OK button

Post by Jennypi »

Thanks but it's not working. The code "this.IsStopped = true;" doesn't stop the report rendering.

Any other idea? :)
Thank you.
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Re: Canceling a forms OK button

Post by Jan »

Hello,

Sorry for troubles with our product!

Usually to stop report rendering you can use IsStopped property of the report, but not in this case. So the correct answer:
Set the DialogResult property of the OK Button to None. After then in ClickEvent of the button right following code:

Code: Select all

if (resultFine) Form1.DialogResult = DialogResult.OK;
Form1.Close();
If you need continue report rendering you set result of the form to OK, otherwise to None.

In attachment you can find sample report.

Thank you.
Attachments
Sample.mrt
(26.39 KiB) Downloaded 207 times
Jennypi
Posts: 361
Joined: Mon Nov 17, 2008 7:13 am
Location: France

Re: Canceling a forms OK button

Post by Jennypi »

Working great!
Thank you Jan for your help!
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Canceling a forms OK button

Post by Alex K. »

Hello,

We are always glad to help you!
Let us know if you need any additional help.

Thank you.
Jennypi
Posts: 361
Joined: Mon Nov 17, 2008 7:13 am
Location: France

Re: Canceling a forms OK button

Post by Jennypi »

Hi

I'm back on this topic as I realize that the code I had written does work properly.

Could you please try to reproduce the problem with the attached example ?
1st situation:
- in the form, type a number
- and click OK
> the report is well displayed.

2nd situation
- in the form, click OK > you get the error message "please enter the first sample number"
- click OK in the error message and enter a number
- click OK in the form
> the report is empty :(

What is wrong with the OK button code?

Thanks for your help!
Attachments
excel source KO_2.mrt
(36.68 KiB) Downloaded 163 times
Data2.csv
(102.34 KiB) Downloaded 175 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Canceling a forms OK button

Post by Alex K. »

Hello,

Please try to use the following code:

Code: Select all

this.IsStopped = false;
if (TextBoxControl1.Control.Text=="")
{
  MessageBox.Show("Please enter the first sample number");
  this.IsStopped = true;
}
else
{
  Form1.DialogResult = DialogResult.OK;
  labels.Connect();
  Form1.Close();
}
Thank you.
Jennypi
Posts: 361
Joined: Mon Nov 17, 2008 7:13 am
Location: France

Re: Canceling a forms OK button

Post by Jennypi »

Working perfectly, thanky you!
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Canceling a forms OK button

Post by Alex K. »

Hello,

We are always glad to help you!

Thank you.
Post Reply