Re: Referring to controls via loops - comments and suggestions
- From: Steve Walker <steve@xxxxxxxxxxxxxxxxxxx>
- Date: Wed, 20 Apr 2005 12:20:11 +0100
In message <#mqAQdZRFHA.2132@xxxxxxxxxxxxxxxxxxxx>, Steve Le Monnier <steve_lemon@xxxxxxxxxxxxxxxxxxxxxxxxx> writes
What is it that you are trying to achieve by this? There may be another approach.
I was trying to reduce the amount of code to write when preparing the controls and they all need to behave the same way, hence tryin to refer to each one via a loop.
I know this isn't the in thing to say, but VB6 allowed you to append strings to the end of a control and then evaluate the entire statement as a command line and not text.
That said, I have found a better way of doing it and that is loading all my controls into an array and then referencing them via the array e.g.
_lnkCostCenters[0] = this.lnkCostCentre1;
_lnkCostCenters[1] = this.lnkCostCentre2;
_lnkCostCenters[2] = this.lnkCostCentre3;
for ( int i = 0; i < _controlCount; i++ )
{
_lnkCostCenters[i].Text = "Department";
}
Ah, I see. You could always subclass the control.
-- Steve Walker .
- References:
- Referring to controls via loops - comments and suggestions
- From: Steve Le Monnier
- Re: Referring to controls via loops - comments and suggestions
- From: Steve Walker
- Re: Referring to controls via loops - comments and suggestions
- From: Steve Le Monnier
- Referring to controls via loops - comments and suggestions
- Prev by Date: Transform?
- Next by Date: Re: Hash value of file?
- Previous by thread: Re: Referring to controls via loops - comments and suggestions
- Next by thread: How can I make all characters in a string upper case?
- Index(es):
Relevant Pages
|