Page 1 of 1

Linked checkboxes in form

Posted: Mon Nov 12, 2012 12:57 pm
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!

Re: Linked checkboxes in form

Posted: Mon Nov 12, 2012 1:20 pm
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.

Re: Linked checkboxes in form

Posted: Mon Nov 12, 2012 1:26 pm
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;
			}

Re: Linked checkboxes in form

Posted: Mon Nov 12, 2012 1:55 pm
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.

Re: Linked checkboxes in form

Posted: Mon Nov 12, 2012 2:06 pm
by Jennypi
In that case, RadioButtonControls will indeed better fit my need.

Thanks a lot!

Re: Linked checkboxes in form

Posted: Mon Nov 12, 2012 2:14 pm
by HighAley
Hello.

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

Thank you.