Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Simple! Moving A Listbox Item For One Lsitbox To Another.


How can I move an item from

lstbox 1 ---> lstbox 2

I want the item to be removed from lstbox 1 and added to lstbox 2

Thanks for anyone who helps.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Moving Item From One Listbox To Another
Hey all

I am trying to move an item from one listbox to another. The first listbox has items where the RowSourceType = "Field List" and the second one is value list. This is my code:

Private Sub DisplayAllFields_DblClick(Cancel As Integer)

If ListOfFieldsSelected.RowSource = (List0.Value & "." & DisplayAllFields.Value) Then
MsgBox ("You cannot select a field more than once. Please select another field")
Else
ListOfFieldsSelected.AddItem (List0.Value & "." & DisplayAllFields.Value)
End If
End Sub

When I double click the same value in the first list again, it brings up the msgbox once but it doesn't do that once it has added another field to ListOfFieldsSelected. I would use the RemoveItem method so user can't click the field again but DisplayAllFields is set to Field List so it can't remove item unless set to "Value list". Any suggestions on this?

Any help will be greatly appreciated.

Many thanks

Rupa

ListBox, Moving From First Item To Second And So On
Hey, im working on a media player, the media player works great but the playlist is screwey! Im having troubble with this:

You select an item for play - 100% ok
it plays it - 100% ok
it then goes to the next item on the list - BUGGY!

it wont move to the next item and when it does, it wont update the selected item eg, it will play the next item then when thats done it will play the one before that not the next on (constant loop between two files). Please help

When Moving Item Down In The Listbox The Text Disappears
Okay dont know why but the text is dissapearing when an item is moved down the list box.

Image1 displays before the move down
Image2 displays after the move down
Code is also attached. I am very confused I have been through this code througherly and I am sure there is not an error in the code.




Code:
' check: only proceed if there is a selected item
' check: last item can't be moved down
' save items text and items indexvalue
' remove item
' place item back on new position
' if you keep that item selected
' you can keep moving it by pressing cmdDown
' for arLoopCount adds the new playlist entrys from
' lstPlayList.
' list1 refreshes
' lstPlayList refreshes
Dim tempStr As String
Dim iIndex As Integer
Dim arLoopCount As Integer
List1.Clear ' Debugging orriented object to display the contents of arFilePlayList Array
If lstPlayList.SelCount = 1 Then
If lstPlayList.ListCount - 1 = lstPlayList.ListIndex Then
Exit Sub
Else
tempStr = lstPlayList.List(List1.ListIndex)
iIndex = lstPlayList.ListIndex
lstPlayList.RemoveItem lstPlayList.ListIndex
lstPlayList.AddItem tempStr, iIndex + 1
lstPlayList.Selected(iIndex + 1) = True
End If
End If
For arLoopCount = 0 To lstPlayList.ListCount
arFilePlayList(arLoopCount) = lstPlayList.List(arLoopCount)
List1.AddItem arFilePlayList(arLoopCount)
Next arLoopCount
List1.Refresh
lstPlayList.Refresh

Moving Listbox Item To Another Listbox
hi does anyone know of an easy way to move an item in a listbox to another listbox, lets say a source and target listbox and vice versa. thanks

Simple Listbox Question - Removing Selected Item
Easy question for you all - how can I have the user click a button and have a select listbox item removed? I cannot seem to get this, as i always needs its index.
To rephase, I need to be able to tell what the index is of the selected item in a listbox, when the contents are changing (the user inputs the contents).
Any ideas would be great! Thanks!

Dragdrop Moving Wrong Item In Listbox(aborted Dragdrop Idea)
I am using dragdrop in a list box(checkbox style) to move items around but sometimes it picks up the item below the one I selected instead of the one I clicked on. ANy ideas? heres the code I'm using

Code:

Private Sub lstFields_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button And vbLeftButton) = vbLeftButton Then
nDragIndex = Y Me.TextHeight("Xyz")
If nDragIndex >= 0 And nDragIndex < lstFields.ListCount Then
blnDraging = True
End If
End If
End Sub

Private Sub lstFields_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim nIndex As Integer
Dim sItem As String

If (Button And vbLeftButton) = vbLeftButton Then
If blnDraging = True Then
nIndex = Y Me.TextHeight("Xyz")
If nIndex > lstFields.ListCount - 1 Then
nIndex = lstFields.ListCount
ElseIf nIndex < 0 Then
nIndex = 0
End If
If nIndex <> nDragIndex Then
sItem = lstFields.List(nDragIndex)
lstFields.RemoveItem nDragIndex
lstFields.AddItem sItem, nIndex
End If
End If
blnDraging = False
End If
End Sub


This is my first post with code in it so I hope I did it right, sorry if I didn't.

Sunflower Queen

Solved-howto Send First Item Of Listbox Totextbox, Then Delete First Item Of Listbox?
Lol another question, how do you do this

how to send first item of listbox to textbox, then delete first item of listbox?

Thanks

###MoVe Items In A ListBOX! Simple Help! Like I Want To Move An Item One Down ###
Hi every1,

ANy1 knws any quick way by which i can move items in a listbox?
Like i have a list box and when i click a button i want the time to be move down by one item in the list or move up by one item...

cud any1 suggest a good method?


thx

How To Search Listbox For Item If Item Not Found Add Item?
Hi, lol man I cant find nothing today when I search the forum.

This my latest problem, How do I search a listbox for an item lets say "Game Over" And if the item is found the program does nothing, but if the item is not found it will add "Game Over"

Thanks Again

Removing An Item From A ListBox By Clicking The Item
Hi, How do you remove an item from a ListBox by simply clicking the item u want to be removed?

This is the code i tried but it doesnt work:

Private Sub list1_Click()
Dim n As Long
Dim ncount As Long

ncount = List1.ListCount - 0
For n = 0 To ncount
List1.RemoveItem (n)
Next
End Sub

Any ideas?


-Flaw

Lsitbox
hi,
how can I select a item from my listbox and made some event occur?
Thanks in advance.
wang

Searching For A Name In A Lsitbox
how would you search for a name in a list box. like if i had a listbox that had these things in it:

blah
blahblah
blahhh

how would i search and find a certain one according to names not index.

Moving To The Next Item In A Pivotfield
I have some code which runs in this For loop.


Code:
For Each PivotItem In ActiveSheet.PivotTables("PivotTable1").PivotFields("Questions").PivotItems
Sheets("Pivot Table").Select
Range("A4").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Sheets("Chart Data").Select
ActiveCell.Select
ActiveSheet.Paste
Sheets("Pivot Table").Select
Selection.End(xlDown).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Sheets("Chart Data").Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
ActiveCell.Offset(3, 0).Select

Next

The item "Questions" is in the page field at the top.

I'd like the code to move to the next item in the page field, and perform the code.

Any idea how it's done?

Listview Item Moving
Hi there,

is it possible to move items in a Listview control(Up and down the list) and how, this one is baffling me

the pig...

Moving A Item In A List Box Up Or Down
I have two buttons on a form and I want the be able to click the up button then move the selected item up or click the down button and have the item go down.

Any Ideas?

Delete Items From A LsitBox
I'm trying to delete items in a listbox that the user has selected. Currently my code deletes half of the items selected. (If 10 items were selected 5 would be deleted from the listbox, and the other 5 will remain). Any suggestions? Thanks


VB Code:
'*CMDVERIFY_CLICK()************************************************************'NAME: cmdVerify_Click()'DESC: Allows the user to verify that they have counted the selected item(s).Private Sub cmdVerify_Click()    Set connection = New ADODB.connection    connection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _        "Data Source= G:FinanceInventory ControlCycleCountDBcycleCount.mdb"    connection.Open        Dim counter As Integer    Do While counter < lstVerificationScreen.ListCount        If (lstVerificationScreen.Selected(counter) = True) Then             Dim selectStatement, sSQL As String            Dim strArray() As String                        strArray = Split(lstVerificationScreen.List(counter), vbTab, -1, 1)                                           selectStatement = "DELETE FROM [MAIN] WHERE ID=" & strArray(0)                        sSQL = "UPDATE [ALTER] SET TYPEOFCHANGE='DELETED' WHERE [MAIN ID]='" & strArray(0) & "'"                        connection.Execute sSQL                        connection.Execute selectStatement             lstVerificationScreen.RemoveItem (counter)                                End If        DoEvents        counter = counter + 1    Loop            connection.Close    Set connection = Nothing    End Sub'*ENDOF*CMDVERIFY_CLICK()******************************************************  

Moving Item Between List Boxes
I have a command button with the Caption ">". When clicked I want the selection the user has made in ListBox1 to be moved to ListBox2.

Anyone ever do something like this before?

thx..

Moving The Selected Item In Listview
****
I solved the problem, thanks to all for your attempt at helping.

Here is the code:

Set ListView.SelectedItem = ListView.ListItems(i)
****

I have a Listview populating from a database and sorts the data alphabetically.

Now when the user deletes an item from the database, it also refreshes the listview.

The question I have is, the listview always sets focus to the last item it added, however it does not add them alphabetically, so after there added and the listveiw sorts them, the item selected could be anywhere!? How can I have this list view set focus to the first entry? Or better yet one that I specify or has been saved (IE save the record ID when they exit the prog, so when they come back I can pull that and set focus to that item)??

Thanks for the help.
Bryan

[This message has been edited by Bryan (edited 01-12-2000).]

Populate A Listbox Based On A Selected Item In Another Listbox
Ok...I am stumped.

I have a single form that has 3 list boxes. I have 4 public strings containing various values. Based on the selection from lstBox1, I need to populate the ListBox2 and ListBox3 list from values in the public strings. Clear as mud?? That is what I thought!

Example string variable

strLuxury = """Hand Wash"" ""Hand Wax"" ""Check Engine Fluids"" ""Detail Engine Compartment"" ""Detail Under Carriage"" ""Fragrance"" ""Shampoo Carpets"" ""Shampoo Upholstery"" ""Scotchgard"""

ListBox1 contains the following:

Standard
Deluxe
Executive
Luxury

ListBox2 is empty, but is contained in a frame indicating Exterior Options
ListBox3 is empty, but is contained in a frame indicating Interior Options

If Luxury is selected in ListBox1, then ListBox2 should contain
Hand Wash
Hand Wax
Check Engine Fluids
Detail Engine Compartment
Detain Under Carriage

And ListBox3 should contain
Fragrance
Shampoo Carpets
Shampoo Upholstery
Scotchgard

If Fragrance is present in ListBox3, a seperate dropdown box should appear allowing selection of the appropriate scent.

Yes, this is a homework assingment.

Thank you in advance for your help!
Mark

Transfering Item From One Listbox To Anotehr Listbox On Click
Hi all i got 2 listbox . I want to be able to click on my first listbox items and once i click on them it transfers to the second listbox. Could any one tell me how that can be done.Thanks

Listbox: How To Know Last Added Item's Index, When The Listbox Is Sorted?
When sorted property of a listbox is set to True, each new item added won't be at the end of the list, it will be automatically placed in the correct index, according to text order, is there a way to know which is the index of that item (last item added)? Looping to find it would be horrendous, I just need the index to mark that item selected.

Using Checkbox In Lsitbox To Save Settings ??
HI,

i'm making a program that wil change registry settings for a user. I want to build in a listbox in checkbox state and the user must be able to click on the item(There by checking it) en then when the press save and the registry settings will be saved. The problem is i dont how how to get selected box's and pass the value's.

Example.: If a user selected NoFind in the list box i must change the dword HKEY_blabanotherkey..NoFind in to 1
normaly i would do this like X=savesettings HKEY_blabanotherkey..check1.value (i when use checkboxes)

But how do i do this with a listbox ??

Thanx in advance for the help

Stop Item Dragging/moving In ListView
Is there any way you can stop the user from moving the item position in a listview?? I need them to stay the same as i added them first by code, with them being fixed for the user and not allowing any movement of item position!

thanks!

Questions: BitBit Moving, Walkmasks And Item Pickups.
Ok, so far have i quickly created a small program where a picture(the guy you control) moves instantly to the location of your click. Theres 3 things i must now:
1. How can i make my guy move slowly to the targeted location? not instantly.

2.How can i create walkmasks? Forexample if i create a tree, and i dont want my guy to walk right through the tree but around it.

3.How can i make my character pick up items? Forexample how can i make my guy get 10 score-points when he moves over an item, which in reality is a picture.

Edit*
I use BitBit.
This is not going to be a real game, iam just testing things out before i start creating a game.
Nothing is animated.

How To Add A Listbox Item To A Listbox On Another Form Within The Project.
What is the best method to take an item selected in a listbox and add it to another listbox on a different form within the same app?

.: Please Help: Copy Selected Item(s) From A ListBox To The Other ListBox..
Hi everyone!

I'm having problem with copying file to another Listbox, please help..
So, in this case, I have two ListBoxes where the 1st ListBox holds several items..
I need to copy the selected item to the other listbox 'without' a repetition, I mean.. the same item won't copied anymore..
When the user tries to copy the item which have already been in the ListBox2, then a messagebox will pop up to warn the user of the existing item.... So, how should I do that??


Thanks a lot

Listbox To Listbox File Moving
I am working on an application where I want to present a current file's field list in one listbox and let the user Click once to highlight it and click a command button to move it from that listbox to another one (for processing). When moved I want it to be gone from the first list and present in the second. Similarly, I have another command button that does the opposite. Can someone give me some ideas of how I actually do this?

Change ListBox Item Text?+ Change Item Color Or Status?
hi
I'm new to VB. I want to change the text of a ListBox item.
I used AddItem to add items.
Then I tried to change a selected item using lst.Text = "somethingNew", but it doesn't work...
Pl. help

And need to know.. how to change the color of an item or status(disable) of an item???

Thanks

Adding An Item From One Listbox To Another Listbox
I have several forms, one with a listbox that displays the selected records of a field from a database. I select(click) one of those records and want to have another particular field from that record display in another listbox on another form. So far it works with this code, but pulls all the records from the first listbox.
To be more specific, the database has populations and zip codes, etc. The field for population is called pop2001 and the zip codes is Zip. The listbox with the selected records displays zipcodes and I want to select one of those zipcodes and have it's population display in the other forms listbox, but it displays all of them. Can anybody help?


Code:
Private Sub Form_Load()

PopRecSet.MoveFirst
Do Until PopRecSet.EOF
frmpopfinal.lstpopfinal.AddItem PopRecSet![pop2001]
PopRecSet.MoveNext
Loop


End Sub

Listbox Name Showing Up As First Item In Listbox?
For some reason the listbox I've just added to my form shows the name of the listbox in itself at design time. At run-time, the name of the listbox shows up as the first item in the list.

I've tried looking for a CAPTION or TEXT property but neither seem to be present. Any ideas as to how to fix this?

Drag Item From Listbox To Listbox
I was wondering how to drag one item from one listbox to another listbox on the same form...
By using drag and drop, not by using any button..
I choose an item by pressing and holding the button and then drag it to the other listbox..

Also,How do I drag a file from outside my app and into the listbox?
How to use the drag and drop (onto apps listbox) function?

Please provide a simple example(form) if you can
PS: Do it as simple as possible!! No need for extra's!!

I need more help, The examples below didnt work correctly!

Simple: Moving Pic With Arrow Keys
How do I move a picture box with the arrow keys?

Simple Moving Of A Picturebox Without Flickering
Here is what i want:

i have a form and a picturebox when the users holds down the mouse on the picturebox the picturebox must move allong with the mouse without flickering, so this is what i have:


Code:
Dim OrX As Single 'original x
Dim OrY As Single 'original y
Dim MsD As Boolean 'check wether mousebutton is pressed

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
MsD = True
OrX = X
OrY = Y
End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If MsD = True Then
Picture1.Left = Picture1.Left + (X - OrX)
Picture1.Top = Picture1.Top + (Y - OrY)
OrX = X
OrY = Y
Refresh
End If
End Sub

Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
MsD = False
End Sub


i can move it now (well a little bit anyway) but it flickers like hell,
PS: picture1.move flickers just as much

Moving Listbox??!!
ok, how do i make an item in a listbox (List1) move into another listbox (List2) after i have selected the item and the pressed a command button. For example: In listbox1 i have an item that says "Hello" then i select it and click the command button then "Hello" moves it from listbox1 into listbox2 and is no longer in listbox1 any more. How do i do this please help!!

Thank You.

Moving From One Listbox To Another
I am currently moving items from one listbox to another the normal way with a loop. However, there can be up to 15,000 records that are moved at one time. Is there an API call that will move all records from one listbox to the other more quickly and efficiently?

Moving Simple Application From Client Server
Well i have developed general ledger(Accounting application)in vb6 .now i have to refine it i want that suppose there are 6 computers.

so i want is database will be located only on one computer which is known as server and other 5 computer will act like client only front are end are installed on them the problem is that what modification i have to doneto make client server architecture
i m using access but ofcourse i will moved towards to sel server

Moving From Simple Application Into Client Server
Well i have developed general ledger(Accounting application)in vb6 .now i have to refine it i want that suppose there are 6 computers.

so i want is database will be located only on one computer which is known as server and other 5 computer will act like client only front are end are installed on them the problem is that what modification i have to done

Moving Items Up And Down In A Listbox
I just solved this question that I've had for a while.

Thought I'd share the code.

http://cornempire.newezone.com/resou...e/listmove.htm

Moving Items In A Listbox
Hi, I have a listbox, with the following:

[case 1]
Msg "Hello"
[case2]
msg "hello"

You can place these items on another dialog.
but, I need it to look like:

[case1]
Msg "hello"
... ---->Open a new space for more Messages when you place one.
[case2]
Msg "hello 2"

This is the code I have so far, but it isnt working.


Code:
Private Sub Command1_Click()
Dim newe As Integer


newe = Newevent.EventList(Eventnum).ListCount
Newevent.EventList(Eventnum).AddItem "<Msg>: " & Text1.Text, newe
'This bit is OK, places the message.

If Newevent.EventList(Index).Text = "..." Then
Newevent.EventList(Index).List(Newevent.EventList(Index).ListIndex) = "..."
Newevent.EventList(Index).List(Newevent.EventList(Index).ListIndex) = "<Msg>: " & Text1.Text
'Only one thing to happen for a Case
'Need it so you can have more than 1 Message under
'case 1, case 2,etc... (Move every ListItem down 1?) -Chris

Dim Position
For n = Newevent.EventList(Index).ListCount To Position + 1 Step -1
Newevent.EventList(Index).List(n) = Newevent.EventList(Index).List(n - 1)
Next
Newevent.EventList(Index).List(Position) = "..."
End If
Exit Sub

Unload events
Unload Me

End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Any help would be appreciated

Chris

Moving Items In Listbox
im trying to get items in a list box to move up and down im not sure how to do it i dont have the first clue wot to do can anyone help with the code?

Moving Listbox View
After picking an item in a Listbox, I want to return it to the top of the list. using listindex just selects an item, but doesn't return whats shown to that item. I want it to display item 0.
How do I accomplish this?
I had:

Code:
ListBox1.ListIndex = 0

but it just highlights the item, but does not show it.
i'm showing one item at a time, and scrolling to the picked item.

Listbox Moving Listindex
i have this code to select the next listindex and if its at the end start at the beggining again.

VB Code:
List1.ListIndex = (List1.ListIndex + 1) Mod List1.ListCount


my question is can anybody come up with a line like that but make it go backwards.
i know you can do if statements to check where the index is but i have been trying to figure this out and i just cant get it right.

thank you.
casey.

Moving ListBox Items
Could anyone tell me how to write a sub that allows you to click and drag an item in a listbox to a new index position within the listbox?

Ash

Moving Items In A Listbox
I have a listbox that has several items in it that i want the user to be able to move up or move down. I have two buttons, one for up the other one for down. Anyone know how to do this? Thanks!

Moving Items In Listbox Down
This code is supposed to move items down 1 spot within the list box with the push of a cmdbutton. I got it to move one item at a time down, but ideally it should move multiple items down at the same time. Any ideas or suggestions would be greatly appreciated. Thank you.

Private Sub cmddown_Click()
Dim Temp As String, Item As Integer

Item = lstShopping.ListIndex

If (Item &gt; -1) And (Item &lt; lstShopping.ListCount - 1) Then
Temp = lstShopping.List(Item)
lstShopping.RemoveItem Item
lstShopping.AddItem Temp, Item + 1
lstShopping.ListIndex = Item + 1
End If
End Sub

Archie Kantzavelos

Moving ListBox To Typing Position.
Hey,

I have a question for you that seems to me as if it could be a hard one... I have not been able to find anything about it, mainly because I haven't got a clue as to where to look for...

I made some sort of AutoComplete feature in my program (in a RichTextBox), and it would be really nice if I could make it similar to Visual Basic's "Auto List Members" option (which is the listbox popping up with possible keywords when you type a ".")

I want a ListBox to become visible whenever the program is autocompleting a word, that lists all other possible keywords (because there are often multiple).

I want this ListBox to appear at the location of the I-beam (selection thingy).

How can I get it to move there? Is it possible to find the Top and Left location of the I-beam inside a RichTextBox somehow? I doubt it...
Can it be done otherwise?

Moving Listbox Items W/ Mouse
does anyone know how to shift listbox items around with the mouse? a good example would be winamp's playlist. the code i came up with works fine...if you move your mouse slowly. if you go fast, it'll pretty much mess up the order because the cursor jumps around when you move your mouse too quickly.


Dim HotItem1 As Integer

Private Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
If HotItem1 <> List1.ListIndex Then
If HotItem1 > -1 Then
a = List1.List(HotItem1)
b = List1
List1.List(List1.ListIndex) = a
List1.List(HotItem1) = b
End If
HotItem1 = List1.ListIndex
List1_Click
End If
Else
HotItem1 = -1
End If

End Sub

Moving Text From Textbox To Listbox
I'm trying to move text from a multiline textbox [Text1] to a list box [List1] but I cant seem to get it :-( Here's what I've done so far.... The code skips some lines. Any help will be appreciated. TIA


Dim CurrStart As Integer
Dim Temp As String 'temp buffer
CurrStart = 1
Temp = Text1 'save text1 to temp
While InStr(CurrStart, Temp, vbCr)
    CurrStart = InStr(CurrStart, Temp, vbCr) 'find the newline
    List1.AddItem Left(Temp, CurrStart) 'add this line to listbox
    Temp = Right(Temp, Len(Temp) - CurrStart) 'remove this line from temp
Wend

Simple: Moving An Image To A Desired Place, But With An Animation Effect
Hello,

I am developing a Snakes and Ladders game, and when someone rolls the dice, this returns a value, and then this value is translated into a value of which the counter on the board must move to. I have managed to make a counter move straight to the target, but I wished for an animated effect where the counter moves across the board at a reasonable speed to the target. I presume a timer would be used for this effect? I am just not sure how I would go about implementing this.

Thankyou in advance
Nick

Edit:

So far I have constructed this code, but what happens is, I set the interval to say 10000, so it waits 10000 milliseconds and then exceutes within the space of one second, which is too quick to really see it moving slowly, how do I slow it down even more? So that it is a smooth move over about 4 seconds or so?

Private Sub Timer1_Timer()
While Image2.Left < 9240
Image2.Left = Image2.Left + 1
Wend
End Sub

I assumed that if I set the interval to 10000 it would run this routine every 10000 milliseconds until the Image2.Left = 9240?

Copyright © 2005-08 www.BigResource.com, All rights reserved