0 Replies - 537 Views - Last Post: 14 July 2009 - 06:23 AM Rate Topic: -----

#1 L1989  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 21-June 09

Using array to shorten text

Posted 14 July 2009 - 06:23 AM

I'm doing a project which contains a part where the form has 40 labels(4 in a row, 10 rows), i need to display colors into these 40 labels and displaying on the same row as the number of my click i.e. first row displays when I click once, I want to shorten this part with array but have encountered problems since I only just started learning

The upper part is the array I've used, the lower one is the original code.

I'm just writing some parts of it since the whole thing is too long. Any help would be appreciated.

							   
Label[] label1 = new Label[] { lblin11, lblin12, lblin13, lblin14,
				 lblin21, lblin22, lblin23, lblin24 }
Label[] label2= new Label[]{lblccolor1,lblccolor2,lblccolor3,lblccolor4};
for (int i = 0; i < 40; i++)
			{
				for (int j = 0; j < 4; j++)
				 
				
					label1[i].BackColor = label2[j].BackColor;
			}

   



								if (intbtnClick == 1)
				{
					lblin11.BackColor = lblpcolor1.BackColor;
					lblin12.BackColor = lblpcolor2.BackColor;
					lblin13.BackColor = lblpcolor3.BackColor;
					lblin14.BackColor = lblpcolor4.BackColor;
					lblout11.Text = string1;
					lblout12.Text = string2;
					lblout13.Text = string3;
					lblout14.Text = string4;
				}
				if (intbtnClick == 2)
				{
					lblin21.BackColor = lblpcolor1.BackColor;
					lblin22.BackColor = lblpcolor2.BackColor;
					lblin23.BackColor = lblpcolor3.BackColor;
					lblin24.BackColor = lblpcolor4.BackColor;
					lblout21.Text = string1;
					lblout22.Text = string2;
					lblout23.Text = string3;
					lblout24.Text = string4;
				}


This post has been edited by L1989: 14 July 2009 - 06:43 AM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1