473,396 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how can i change the position of an item in the list box in c#.net with asp.net2.0?

app98
2
I am preparing a listbox it contains some items and it has two buttons ( up button and down button), when i pressed down button item was changing its position from up to down , but when iam pressing the up button it is not moving ????..this is my prob what to do pls make me clear.......... iam doing it in c#.net with asp.net2.0
Sep 2 '06 #1
1 7130
private void button2_Click(object sender, System.EventArgs e)
{
//// UP
if (listBox1.SelectedIndex >0)
{
String Temp = listBox1.Items[listBox1.SelectedIndex].ToString();
listBox1.Items[listBox1.SelectedIndex] = listBox1.Items[listBox1.SelectedIndex-1];
listBox1.Items[listBox1.SelectedIndex-1] = Temp;
listBox1.SelectedIndex--; // folow up by placing the selection again
}
}

private void button3_Click(object sender, System.EventArgs e)
{
if (listBox1.SelectedIndex < listBox1.Items.Count-1)
{
String Temp = listBox1.Items[listBox1.SelectedIndex].ToString();
listBox1.Items[listBox1.SelectedIndex] = listBox1.Items[listBox1.SelectedIndex+1];
listBox1.Items[listBox1.SelectedIndex+1] = Temp;
listBox1.SelectedIndex++; // folow up by placing the selection again
}
}
Jan 16 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: BillB | last post by:
When I activate frmList.List0, it positions at the end of the table: - frmList Private Sub Form_Activate() Me.List0.SetFocus Me.List0.ListIndex = Me.List0.ListCount - 1 - When I DblClick a...
1
by: darkom | last post by:
CAN I CHANGE POSITION OF OPENFILEDIALOG IN VB.NET? I WONTH OPEN DIALOG ON X=0 AND Y=0 POSITION. THANKS
1
by: Joerg Battermann | last post by:
Hello there, does anyone know whether it is possible to change Window's "List Seperator" (Start -> Control Panel -> Regional and Language Options -> Customize -> List Seperator) value...
6
by: Jakob Bieling | last post by:
Hi, I want to move an element from a std::list to the end of the same list. To get this done, I thought I'd just do something like: std::list <intlst; lst.push_back (0); lst.push_back (1);...
3
by: Prashant Mahajan | last post by:
Hi All, I am facing a problem regarding accessing the item list of an XML node in IE. While using the following code: for(test in XMLNode) {} I received this XML Node from AJAX's...
7
by: colin | last post by:
Hi, I have my property editor wich uses the pop up collection editor for arrays etc, but i have had to use a generic wrapper for the elements in some types of collections. although the editing...
0
by: Medardo Rodriguez (Merchise Group) | last post by:
On Sun, Aug 24, 2008 at 10:17 AM, Carson Farmer <carson.farmer@gmail.comwrote: You gave the solution yourself. I don't know if your inner polygons can contain lines and polygons, or only...
1
by: Montezuma's Daughter | last post by:
Hi All I want to change the position of alert() msg . is it possible to manipulate it like other windows? thanks
4
by: Peter | last post by:
I have a DataList and each item in the datalist has an imge, I want to change the datalist item image on the client side when user clicks a button. How would I do that with JavaScript, does anyone...
12
by: Richard Penfold | last post by:
I am developing an order tracking database, which to keep this explanation simple, consists of 'Orders' table, 'Order Details' table, 'Deliveries' table & 'Inventory' table. There are one-to-many...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.