Automatic Brush Selection ( by int i )

  • Thread starter Thread starter djp
  • Start date Start date
D

djp

hi
I have int i = 0 that changes to max 20

I need to select different brushes depending on this 'i'.
How to do this?
I cannot do something like this: Brushes... :/

Thanks for any help
PK
 
djp said:
I have int i = 0 that changes to max 20

I need to select different brushes depending on this 'i'.
How to do this?
I cannot do something like this: Brushes... :/


First prepare your brushes:

List<Brush> myBrushes = new List<Brush>;
myBrushes.Add(Brushes.Black);
myBrushes.Add(Brushes.Aqua);
... (Add your 20 brushes)

Then, when you want to select one of your bruses, just extract it from
the List:

Brush selectedBrush = myBrushes.Item(i);
 
PK,

Why can't you do it? Just create an array of 21 elements (0 to 20) and
then associate brushes with each element. You just have to make sure that
you are populating the brush array before you try and use an index to access
it.

Hope this helps.
 
Thanks. I just tought that there is an easier way.
Why can't you do it? Just create an array of 21 elements (0 to 20) and
then associate brushes with each element. You just have to make sure that
you are populating the brush array before you try and use an index to
access it.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

djp said:
hi
I have int i = 0 that changes to max 20

I need to select different brushes depending on this 'i'.
How to do this?
I cannot do something like this: Brushes... :/

Thanks for any help
PK

 
Back
Top