Groups | Blog | Home
all groups > dotnet general > march 2004 >

dotnet general : creating label control arrays


Raju
3/17/2004 11:01:08 PM
Hi

I am working with one Window based application in C#. I want to create label control arrays, say instead of label1, label2, label3 i need to have it as label[1..3]

So please let me know how to create label arrays using C#. I believe this is possible with VB or VB.NET. But i am not whether it is possible with C#, but i need to do this with C#

Thanks in advance..

Thanks
William Ryan eMVP
3/18/2004 9:24:46 AM
Control Arrays don't exist in .NET. however, you can simulate the
functionalityb by adding handlers for each of the other controls.

So :

this.label1.Click += new System.EventHandler(this.label1_Click);

this.label2.Click += new System.EventHandler(this.label1_Click);

this.label3.Click += new System.EventHandler(this.label1_Click);

[quoted text, click to view]
label control arrays, say instead of label1, label2, label3 i need to have
it as label[1..3].
[quoted text, click to view]
is possible with VB or VB.NET. But i am not whether it is possible with C#,
but i need to do this with C#.
[quoted text, click to view]

Cor
3/18/2004 4:20:28 PM
Hi Raju,

Do you mean this?

{Label[] labelAr = {label1,label2,label3};
labelAr[1].BackColor = Color.Red;}

Cor

[quoted text, click to view]
label control arrays, say instead of label1, label2, label3 i need to have
it as label[1..3].
[quoted text, click to view]
is possible with VB or VB.NET. But i am not whether it is possible with C#,
but i need to do this with C#.
[quoted text, click to view]

AddThis Social Bookmark Button