Page 1 of 1

disable specific text controls controls at once

Posted: Tue Dec 02, 2008 8:46 pm
by Pio Leonardo V. Rapirap
say I have 20 text controls

txtHeader1.Enabled = false;
txtHeader2.Enabled = false;
txtHeader3.Enabled = false;
.
.
.
txtHeader20.Enabled = false;

how can I achieve this?

txtHeader[index].Enabled = false;
txtAnotherSetofTextCtrls[index].Enabled = false;
:dumb:

any help is highly appreciated




disable specific text controls controls at once

Posted: Tue Dec 02, 2008 11:24 pm
by Vital
Hello,

You can use following code from your application:

report.GetComponentByName("txtHeader1").Enabled = false;

Thank you.


disable specific text controls controls at once

Posted: Wed Dec 03, 2008 9:24 pm
by Pio Leonardo V. Rapirap
Vital wrote:Hello,

You can use following code from your application:

report.GetComponentByName("txtHeader1").Enabled = false;

Thank you.
I'm sorry if I didn't make myself clear.

What I am trying to do is to disable all controls (in my case I have 20 text controls)
using a for loop

It took time for me to figure it out
and here's what I did to make it work

Code: Select all

int intIndex = 0;
for(int ctr=1; ctr<=20; ctr++){
  	intIndex = ctr;
	string index = intIndex.ToString();
	string controlname = "txtHeader"+intIndex;
	StiText text = new StiText();
	text = GetComponentByName(controlname) as StiText;
	text.Enabled = false;
}
and fortunately, it worked!

my only problem now is how to convert this into a reusable function
Any Advise?

Great Thanks!

disable specific text controls controls at once

Posted: Thu Dec 04, 2008 1:22 am
by Edward
Hi.

There are two possible ways for adding of the function:

1. As it is shown here:

http://www.stimulsoft.com/livedemos/Rep ... ction.html

2. You can define that function inside of the report, in the report designer. Click in the Code Tab and define that function in any place there but outside the following region:

#region StiReport Designer generated code - do not modify

Code inside of this region is being updated each time any changes are made for the report in the Designer.

Thank you.