disable specific text controls controls at once

Stimulsoft Reports.NET discussion
Post Reply
Pio Leonardo V. Rapirap
Posts: 7
Joined: Wed Nov 26, 2008 1:40 am
Location: Philippines

disable specific text controls controls at once

Post 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



Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

disable specific text controls controls at once

Post by Vital »

Hello,

You can use following code from your application:

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

Thank you.

Pio Leonardo V. Rapirap
Posts: 7
Joined: Wed Nov 26, 2008 1:40 am
Location: Philippines

disable specific text controls controls at once

Post 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!
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

disable specific text controls controls at once

Post 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.
Post Reply