Linked checkboxes in form

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

Linked checkboxes in form

Post by Jennypi »

Hi all,

In one of my reports I have a form with multiple checkboxes.
Is there an easy way (in the events maybe?) to automatically uncheck a checkbox when user selects another?
Can you please provide me with a example of code to include in an event?
(I'm using the user interface, I'm not coding)

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

Re: Linked checkboxes in form

Post by Alex K. »

Hello,

You can use the following code:

Code: Select all

foreach (StiComponent comp in Form1.Components)
{
    if (comp is StiCheckBoxControl)
        ((StiCheckBoxControl)comp).Checked = true;
}
Thank you.
Jennypi
Posts: 361
Joined: Mon Nov 17, 2008 7:13 am
Location: France

Re: Linked checkboxes in form

Post by Jennypi »

Thanks for your quick reply.
Where should I insert this code? Sorry I'm not very used to use code.
I tried this (in the Code tab) but got errors ("Type or name space name StiCheckBoxControl cannot be found"):

Code: Select all

using System;
...
namespace Reports
{public class Report : Stimulsoft.Report.StiReport
    {public Report()
        {
         this.InitializeComponent();
			this.PrinterSettings.PrinterName="...";
			foreach (StiComponent comp in Form1.Components)
			{
				if (comp is StiCheckBoxControl)
					((StiCheckBoxControl)comp).Checked = true;
			}
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Linked checkboxes in form

Post by HighAley »

Hello.
Jennypi wrote:In one of my reports I have a form with multiple checkboxes.
Is there an easy way (in the events maybe?) to automatically uncheck a checkbox when user selects another?
Can you please provide me with a example of code to include in an event?
(I'm using the user interface, I'm not coding)
It seems that it's better to use RadioButtonControls instead of the CheckBoxControls.
They have such behaviour by default.

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

Re: Linked checkboxes in form

Post by Jennypi »

In that case, RadioButtonControls will indeed better fit my need.

Thanks a lot!
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Linked checkboxes in form

Post by HighAley »

Hello.

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

Thank you.
Post Reply