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
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
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
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
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
How To Get The Text Of Item In A Listbox?
I am using a test tool that uses VBA as its back end. When I record the action the tool itself only recongnizes the NAME of the item selected in the list...in most cases this is best.
However, I really need it to select by text, but this does not seem to work. So I want to write a little VBA that will extract the text of the displayed selection in the listbox after my test tool plays back the selection.
Example:
the text displayed is "English"
the name of this item is "en-US"
I want:
textDisplayed = text.listbox, which will mean textDisplayed = "English"
I was wondering what the syntax for this is? rather new to VB.
Thanks in advance
Listbox Item Text
Hello, i want to display the text in a listbox item.
list1.text will display for the selected text
however,
i want to obtain the text for a particular item in the list
ie: get list1 item 3's text
Listbox - Changing The Text Of Item
Hi I have included an example in the zip file to show what i'm trying to do:
I have three checkoption boxes - Apple, Banana and Orange and
a listbox (list1)
When the checkbox is ticked the item appears in the list1 listbox - All this works fine but now I need to do one more thing
If the items Apple, banana and orange are in the listbox I need to be able to change the item name into its colour for example on double click turn:
The text 'apple' into the text 'Green' or the text 'banana' into 'Yellow' or 'orange' into the text 'same as fruit' - but only the item selected and not all of them in one go
Because I want to be able to keep some items as the fruit name and change others to the colour of the fruit
Is this even possible and if so any advise on how to do it?
Modify The Text In A Listbox Item
I have a list box in a Excel Form. at some point i want to modify the text of the selected item in the list box. When i use lstItems.Text="xyz", its not accepting.
I dont want to delete and add the item as there is no "sort" option for the listbox. If anybody knows please let me .
Thanks
Vijay S
Listbox Text Item Forecolor
I have a List box with a number of entries listed from a database.
I need a way of changing the font style to italic for an individual entry on a certain condition:
For example:
If the text of say listindex number 2 = "Products" then i need just that line to be italic
is it possible using ordinary listboxes?
thanx
clax
Removing An Item From A Listbox Specifing The Text
hi to all!!!
first of all... good forum! i'm a newbie , i have just registered
(... i'm italian... )
my question is:
can I remove an item from a list box specifing the text?
example: I write the caption of a listbox item and by clicking a button i want to remove it.
(.. I hope you have understood )
simply: i want to remove an item specifing the caption and not the index of the item
greetz
simons
Listbox: Change Text Of Selected Item
hi all,
just wondering if anyone knows a way of changing the text of the selcected item in a list box?
for example: if i have a listbox with the following list items:
one
two
three
four
and "two" is selected, and i need to change its text to "this one".
i would like to avoid regenerating the list by clearing it and adding all the items again if possible.
thanks for your time and consideration,
mojoinst
Listbox Scrollbar Disappears When I Resize It
If I resize a listbox using it's height property, it's scrollbar disappears for some reason. How can I prevent that or make it reappear ?
An example:
I use the AddItem method to add items to the ListBox, and when the window is filled up, the vertical scrollbar appears by itself and does its job. However when i resize the ListBox by modifying the Height property of the ListBox, the scrollbar vanishes and never comes back.
What am I not doing right ?
Please help. This is getting annoying
Listbox Remove Item By Matching Text With A Textbox
Is it possible to remove a item from a listbox but no using index removing a item with the same text as the text in a textbox instead.
Eg
I had a listbox with this in
Hello1
Hello2
Hello3
Hello4
and i had a textbox with the text
Hello4
in it.
Is it possible to remove a item from the listbox by matching the text in the textbox with the same text in a the listbox and then removing that item.
vb Code:
list1.removeitem (text1.text)
I no that wont work, just i don't really know how to explain it.
Thanks
Quick Question: Listbox And Substituting Text For List Item
Ok, here's the problem: I've got my listbox right? I have a whole bunch of list items in the list box that have a very very long caption. Now what I want to happen is when a user clicks one of those captions, it is to have some DIFFERENT text to be stored into a variable. Like I click the list item, a separate piece of text is then stored into a string variable. Then later on, in a different form, I want to be able to use that variable to display the text instead of the text in the list box. I have some code set up but I am not exactly sure how to manipulate it.
VB Code:
Private Sub List1_Click(Index As Integer)Dim NPC1 As StringNPC1 = List1(0).TextDim NPC2 As StringNPC2 = List1(1).TextDim NPC3 As StringNPC3 = List1(2).TextDim NPC4 As StringNPC4 = List1(3).TextDim NPC5 As StringNPC5 = List1(4).TextDim NPC6 As StringNPC6 = List1(5).TextDim NPC7 As StringNPC7 = List1(6).TextDim NPC8 As StringNPC8 = List1(7).Text End Sub
Do I need to like have a line after that, that states:
VB Code:
Private Sub List1(6).Text_Click()NPC1 = ["textblahblah"]
Thanks!
(? Help) Change Listbox Selected Text Without .additem Or .remove Item
Hi, I browsed through posts and didnt see this question elsewhere so I hope I didnt miss it if it was answered already. If so im sorry.
I was wondering if there is anyway to change the selected text entry for a list box without adding or removing an item.
Example: If there were these options in a list box:
A
B
C
and "B" had been selected by the user is there anyway to change "B" to "D" without using the .additem or the .remove command? If you need me to restate or clarify what im asking please let me know and Ill repost as soon as I see it. Thanks for any help I get in advance.
- Sidenote: I would use a loop and simply add them into another list box and back into that one in a different in the correct order but theres some sticky and touchy coding done on the list box's _click statement that really wouldnt make such a loop possible....if this sidenote didnt make sense sorry its 5 am .
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
DrawString Text Disappears
I am using very simple DrawString code. The text displays, but after resizing the form, it goes away. Is there some additioinal call I need?
The code is something like:
Dim gr As Graphics = Me.ipInkPicture.CreateGraphics
gr.DrawString("This is a test", Font, Brushes.Black, x, y)
gr.Flush(Drawing2D.FlushIntention.Sync)
Highlighted Text Disappears
Hi,
I am coding a MUD client. The client has the incoming text stored in an RTF Text Box. Whenever text is highlighted, no cut or any command done, it disappears when you press enter. It also has this problem when you hit a button.
Thanks!
Combo Box Text Disappears!
I have a combo box that's supposed to show all values in a given database. The procedure works fine until it gets to the end, then for some reason the combo box loses its text. The list items are there, it just no longer shows the item I selected. I ran a quick debug, and it happens right on the first Exit Sub (the one before the error handler.)
Code:
Private Sub MasterControl_Click()
Set fso = New FileSystemObject
On Error GoTo ErrorHandler
MasterControl.Text = Replace(MasterControl.Text, " ", "")
If fso.FileExists(App.Path & "Databases" & MasterControl.Text & ".mdb") = False Then
For i = 0 To MasterControl.ListCount
If MasterControl.Text = MasterControl.List(i) Then
MasterControl.RemoveItem i
End If
Next i
Set rs = New ADODB.Recordset
RecordSource = "SELECT * FROM Headers ORDER BY Name"
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "DatabasesHeaders.mdb"
rs.Open RecordSource, ConnectionString, adOpenKeyset, adLockOptimistic
If Not rs.BOF Then
rs.MoveFirst
End If
For i = 1 To rs.RecordCount
If rs!Name = MasterControl.Text Then
rs.Delete adAffectCurrent
Else
rs.MoveNext
End If
If rs.EOF = True Then Exit For
Next i
End If
OrganizerDatabase.ListItems.Clear
Set rs = New Recordset
Set Win32Script = CreateObject("WScript.Shell")
For i = 0 To Data.Count - 1
Data(i).Locked = False
Data(i).BackColor = vbWhite
Next i
RecordSource = "SELECT * FROM " & MasterControl.Text & " ORDER BY SiteName"
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "Databases" & MasterControl.Text & ".mdb"
Win32Script.RegWrite "HKEY_CURRENT_USERSoftware" & App.Title & "CurrentSelectedItem", MasterControl.Text
rs.Open RecordSource, ConnectionString, adOpenKeyset, adLockOptimistic
If rs.BOF = False Then
rs.MoveFirst
End If
For i = 1 To rs.RecordCount
If rs.EOF = True Then Exit For
OrganizerDatabase.ListItems.Add , , rs!SiteName
rs.MoveNext
Next i
Set fso = Nothing
Set rs = Nothing
Set Win32Script = Nothing
Exit Sub
ErrorHandler:
MsgBox "Error #" & Err.Number & ": " & Err.Description, vbCritical, "Program Error"
Exit Sub
End Sub
Combo Text Disappears
Hi All,
Here's a strange one. I have 2 combo boxes of the same type on screen. I also have 2 grids and the grids are bound to different ADO recordsets. When I select an item from one of the combos the recordpointer on the associated grid moves to the item where a column has the associated value and all is fine. I do exactly the same with the other combo and grid, but after the recordpointer has moved on the grid, the value in the combo disappears. When stepping the code at the 'End Sub' line of the combo's click event the correct values are still in the combos text property. As soon as I F8/F5 off, the text disappears. I've removed and replaced the control, put debug statements into every event incase somthing else is triggering and nothing is.
Text Disappears In Chart In VB Report
Helllo, I have a excel file with a chart that I'm trying to imbed into my VB report. (the sheet is actually updated by a macro in the VB)
Everything looks fine in design mode, but when I preview or print the text (legend and values) dissapear. Is this a size issue or Is there another way to get the chart on my report. Thanks!
Text Disappears When Focus Is Lost?
txtMyRef.Text Properties:
Data Field = MyRef
DataSource = adcInvoiceDisplay
adcInvoiceDisplay Properties:
Command Type = 8 - adCmdUnknown
RecordSource = "SELECT * FROM Invoice"
If the RecordSource has a specific index, then the text field is ok, however on start up, if the database is empty, i type something in the text field, change the focus to another field, and the text vanishes, as though the ADODC is still trying to load data that doesn't exist yet?
Any ideas?
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
Picturebox Text Disappears When Backcolor Changed (RESOLVED)
Changing the backcolor as below causes the text in it not to appear.
Any ideas?
Code:Picture2.Cls
Picture2.Print Format(tr1, "fixed"); Chr(10);
If tr1 >= 1.5 Then Picture2.BackColor = vbGreen Else Picture2.BackColor = vbWhite
Also,While I'm here, , how can I choose a fixed no. of decimal places? In the code above it is set to 2.
Thanks for any help
Jim
Edited by - jimvt on 6/18/2004 4:54:02 AM
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?
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
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.
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.
.: 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?
Text Box Text Disappears
I am using the following code.
Code:
Private Sub txtData_KeyPress(Index As Integer, KeyAscii As Integer)
Dim strText As String
Dim rsText As ADODB.Recordset
Dim i As Integer
If KeyAscii = 13 Then
strText = "select * from TableName where Field_Name='"
strText = strText & txtData(0).Text
strText = strText & "'"
Set rsText = New ADODB.Recordset
rsText.Open strText, strConnStr, adOpenStatic, adLockPessimistic
For i = 0 To rsText.Fields.Count - 1
If IsNull(rsText.Fields(i).Value) Then
txtData(i).Text = ""
Else
txtData(i).Text = rsText.Fields(i).Value
End If
Next
End If
End Sub
User enters value from the field in txtData(0) and will press 'Enter' key. When observed during debugging, all the text boxes will have appropriate value. But, when the control comes out of End Sub, txtData(0) becomes blank. Does any one know why it happens?
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!
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?
|