Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,

I have two buttons(load,up)
when i press load button , dynamic labels are loaded as

label0
label1
label2
label3
label4
label5


then i click any label in that from above and press up button it should come first
example:

wen i click label4 it should come like this,

as

output:
label4
label0
label1
label2
label3
label5
Posted
Updated 15-Aug-13 20:20pm
v2
Comments
ridoy 14-Aug-13 5:44am    
so do that.
chandraaa 16-Aug-13 2:22am    
k thanksss.. i asked code....
Sushil Mate 14-Aug-13 6:12am    
simple isn't it?
chandraaa 16-Aug-13 2:23am    
so simply but dnt know the code...
BillWoodruff 14-Aug-13 10:11am    
What 'Container Control' are Labels 0~5 in now ? Are those Labels the only things in their container ? What are you doing now to detect which Label is 'Selected: that is, which Label you will move when you click the 'Up Button ? Show some code, please.

You can add dynamically label to you form like below :

C#
static int labelID;
        protected void btnload_Click(object sender, EventArgs e)
        {
            Label label = new Label();
            label.ID = "Label" + labelID;
            label.Text = "Label" + labelID;
            form1.Controls.Add(label);
            labelID++;
        }


Then for moving up label use solution 1 that is better and easy way.

Accept as answer and vote if help to you.
 
Share this answer
 
v2
Rather than actually moving the labels, I would suggest you would need better off just moving the label content - it's Text property - which is a lot easier to do, and will probably look better while it is happening as well. It's also a piece of came to code:
C#
string temp = label1.Text;
Label1.Text = label2.Text;
Label2.Text = label3.Text;
...
Label7.Text = label8.Text;
Label8.Text = temp;
 
Share this answer
 
v2
Comments
jaideepsinh 16-Aug-13 3:08am    
5 +VE.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900