Sorry Cor,
I was a bit vague. Since I wrote this I found my old test code I wrote in
VB6. I ran it through the upgrade wizard and it produce the following code
(aimple form, listbox and two commend buttons) This should
explain/demonstrate what I am trying to do. I could implement this as it
stands, it works, but it needs reference to the VB6 Compatibility. However,
I would like to do it completely in .NET. Does this make sense?
__________________________________________________ _____________________
Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal
eventArgs As System.EventArgs) Handles Command1.Click
Dim lposition As Short
Dim lposition2 As Short
Dim My_string1 As String
Dim My_string2 As String
'gj - to shuffle position of selected item.
'find position
lposition = List3.SelectedIndex
'find if already top of list
If lposition = 0 Then Exit Sub
lposition2 = (List3.SelectedIndex) - 1
My_string1 = VB6.GetItemString(List3, lposition)
My_string2 = VB6.GetItemString(List3, lposition2)
'find if list if empty
If My_string1 = "" Then Exit Sub
VB6.SetItemString(List3, lposition2, My_string1)
VB6.SetItemString(List3, lposition, My_string2)
List3.SelectedIndex = (List3.SelectedIndex) - 1
End Sub
Private Sub Command2_Click(ByVal eventSender As System.Object, ByVal
eventArgs As System.EventArgs) Handles Command2.Click
Dim lposition As Short
Dim lposition2 As Short
Dim My_string1 As String
Dim My_string2 As String
'gj - to shuffle position of selected item.
'find position
lposition = List3.SelectedIndex
'find if already end of list
If lposition = (List3.Items.Count - 1) Then Exit Sub
lposition2 = (List3.SelectedIndex) + 1
My_string1 = VB6.GetItemString(List3, lposition)
My_string2 = VB6.GetItemString(List3, lposition2)
'find if list if empty
If My_string1 = "" Then Exit Sub
VB6.SetItemString(List3, lposition2, My_string1)
VB6.SetItemString(List3, lposition, My_string2)
List3.SelectedIndex = (List3.SelectedIndex) + 1
End Sub
Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs
As System.EventArgs) Handles MyBase.Load
List3.Items.Add("Blue")
List3.Items.Add("Red")
List3.Items.Add("Green")
List3.Items.Add("Pink")
List3.Items.Add("Orange")
List3.Items.Add("Maroon")
End Sub
________________________________________________
"Cor Ligthert" <no************@planet.nl> wrote in message
news:uR**************@TK2MSFTNGP12.phx.gbl...
Jonesgj,
I assume that you use a windowform.
Then the place in the listbox says nothing about a place in a database.
Assuming you use the datasource only a reference to a row in a datatable,
which is itself unordered.
So what is it you want to archieve
Cor
"Jonesgj" <g@btinternet.com>
Hi,
I have loaded a listbox with items from a database. I now want to allow
the
user to re-order the list box manually using up down buttons, before
submitting his changes to back to the database.
I did this sometime ago in classic vb, and I think I used the Listindex
property to check ... anyway, can anyone help?
Thanks in anticipation
JonesGJ