Listbox sort
-
Hello everybody, I don't know if it is posible do with a listbox or other object but i need to choose the order of a list of address for create later a route of trucks.(not sort by asc or desc) I want that a user can up o down a row of a listbox (or other object) for this election later save in a table. I am working with asp.net and vb.net I attach a picture for that you understand me better (my english is not good, sorry) Thanks for your help http://www.myleonberger.net/listbox.jpg
-
Hello everybody, I don't know if it is posible do with a listbox or other object but i need to choose the order of a list of address for create later a route of trucks.(not sort by asc or desc) I want that a user can up o down a row of a listbox (or other object) for this election later save in a table. I am working with asp.net and vb.net I attach a picture for that you understand me better (my english is not good, sorry) Thanks for your help http://www.myleonberger.net/listbox.jpg
-
Hello everybody, I don't know if it is posible do with a listbox or other object but i need to choose the order of a list of address for create later a route of trucks.(not sort by asc or desc) I want that a user can up o down a row of a listbox (or other object) for this election later save in a table. I am working with asp.net and vb.net I attach a picture for that you understand me better (my english is not good, sorry) Thanks for your help http://www.myleonberger.net/listbox.jpg
If I understand you correctly, you want to be able to order the items in a list box manually, to arrange the route order. Strictly the list box isn't sorted, but ordered. I assume you want this done without postback until finished, AFAIK (but I could be wrong) there are no out-the-box .net controls to do this, I found this, hopefully it will be helpful: http://www.velocityreviews.com/forums/t76756-set-display-order-of-listbox-control.html[^]
ragnaroknrol The Internet is For Porn[^]
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners. -
Hello everybody, I don't know if it is posible do with a listbox or other object but i need to choose the order of a list of address for create later a route of trucks.(not sort by asc or desc) I want that a user can up o down a row of a listbox (or other object) for this election later save in a table. I am working with asp.net and vb.net I attach a picture for that you understand me better (my english is not good, sorry) Thanks for your help http://www.myleonberger.net/listbox.jpg
I don't think the listbox will maintain the rearranged order if you do it with javascript on the client side. What kind of database fields do you have behind it? Is there a column to hold the sort order? You could figure out how may items you are dealing with and dynamically add hidden fields with numbers in their name MyHidden0, MyHidden1 and so on. Then with javascript in the onclientclick of your save button have a function that loops through the options in the listbox and assigns the values to the hidden field. Then you know that the item in MyHidden0 should have sort order 0 and MyHidden1 has a sort order of 1.
-
I don't think the listbox will maintain the rearranged order if you do it with javascript on the client side. What kind of database fields do you have behind it? Is there a column to hold the sort order? You could figure out how may items you are dealing with and dynamically add hidden fields with numbers in their name MyHidden0, MyHidden1 and so on. Then with javascript in the onclientclick of your save button have a function that loops through the options in the listbox and assigns the values to the hidden field. Then you know that the item in MyHidden0 should have sort order 0 and MyHidden1 has a sort order of 1.
the first thanks for your ideas, even I am thinking about it because I don't know like up or down items of my listbox with 2 button (up, down) and that user see it. The idea is can put order in listbox for later print a sheet of route for trucks, the first item will be the first customer for distribute and last item will be the last customer for distribute but doesn't exist a rule to order like asc or desc etc, it must be done by user like he wants. the idea after listbox is ordered is save this information to table for later print. Well, at the moment I will be happy to know like can up or down items of listbox with two buttons, later know like save it in array. I imagine that for sample if the item 7 of my listbox I push 3 times my button of "up" it will be my future item 4 but the problem is that my old item 4 now will be item 5 and my old item 6 will be item 7, haha I am losing myself :confused: Thanks for your ideas ;)
-
the first thanks for your ideas, even I am thinking about it because I don't know like up or down items of my listbox with 2 button (up, down) and that user see it. The idea is can put order in listbox for later print a sheet of route for trucks, the first item will be the first customer for distribute and last item will be the last customer for distribute but doesn't exist a rule to order like asc or desc etc, it must be done by user like he wants. the idea after listbox is ordered is save this information to table for later print. Well, at the moment I will be happy to know like can up or down items of listbox with two buttons, later know like save it in array. I imagine that for sample if the item 7 of my listbox I push 3 times my button of "up" it will be my future item 4 but the problem is that my old item 4 now will be item 5 and my old item 6 will be item 7, haha I am losing myself :confused: Thanks for your ideas ;)
I found the solve very easy :) You only call to this sub from button up Regards
Sub MoveSelectedItemUp(ByVal Box As ListBox) Dim Index As Integer = Box.SelectedIndex 'Index of selected item Dim Swap As Object = Box.SelectedItem 'Selected Item If Not (Swap Is Nothing) Then 'If something is selected... Box.Items.RemoveAt(Index) 'Remove it Box.Items.Insert(Index - 1, Swap) 'Add it back in one spot up 'Box.SelectedItem = Swap 'Keep this item selected End If End Sub