What exactly is the issue?
.moving the items up/down?
.or selecting the previously selected.Item with a new Index?
codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
Thanks for input NewUserVB.Net, though I'll wait for the o.p's(original.poster's) input on this; only makes sense Not to go way out of my way, when I possibly only have to walk a few steps Then be back on my original.path.:)
codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
Not really, though close.
With ListBox1
If Not .SelectedIndex = -1 Then '// if .item selected.
Dim L1SI As String = .SelectedItem
'// run code here for up/down.
.SelectedItem = L1SI
End If
End With
codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
>>Got it?
.will try to get it.Then reply.:)
codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
2.Buttons,1.ListBox,new.Project
Imports System.IO
Public Class Form1
#Region "-----===-----===-----=== DECLARATIONS ÆND STUFF ===-----===-----===-----"
Private btnUp, btnDown As Button, lbMain As ListBox '// If you need control, you make your own.
Private iT, iM As Integer, sT As String '// TEMP sh.t.
#End Region '===-----===-----===-----'
#Region "-----===-----===-----=== START.UP ÆND SH.T===-----===-----===-----"
Private Sub loadMyCoolApp()
Me.Font = New Font("verdana", 10, FontStyle.Bold) '// just.because.
btnUp = Button1 : With btnUp : .Text = "^" : .Cursor = Cursors.Hand : End With '// take control of code.
btnDown = Button2 : With btnDown : .Text = "v" : .Cursor = Cursors.Hand : End With '// loose control of code. xD
lbMain = ListBox1 : With lbMain.Items : .Add("Guava") : .Add("Apple") : .Add("Pineapple") '// set.load ListBox.
If Not .Count = 0 Then lbMain.SelectedIndex = 0 Else toogleUpDown()
End With
End Sub
Private Sub toogleUpDown()
iT = lbMain.SelectedIndex : btnUp.Enabled = False : btnDown.Enabled = False '// lights.off.
If Not iT = -1 Then '// if item selected Then lights.on.
If iT > 0 Then btnUp.Enabled = True
If iT < lbMain.Items.Count - 1 Then btnDown.Enabled = True
End If
End Sub
Private Sub relocateItems(ByVal selBtn As Button)
With lbMain
sT = .SelectedItem '// get.Item Value.
iM = .SelectedIndex '// get.Item Index and some.
.Items.Remove(.SelectedItem) '// .Remove.Item.
If selBtn Is btnUp Then .Items.Insert(iM - 1, sT) '// .insert.Item. why -1?, cause it worx.xD
If selBtn Is btnDown Then .Items.Insert(iM + 1, sT) '// .insert.Item. why +1?, cause it worx.xD
.SelectedItem = sT '// highlight item again.
Exit Sub '// get the f.ck out since done.
End With
'// u.still here? :-\; Then get the f.ck out. ;)
End Sub
#End Region '===-----===-----===-----'
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
loadMyCoolApp()
End Sub
Private Sub _coolButton_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click, Button2.Click
relocateItems(CType(sender, Button))
End Sub
Private Sub _ListBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
toogleUpDown()
End Sub
End Class
codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384