Quick Listbox Questions (Move To Next Item)
Simple: Listbox and cmd button.
When I click the command button, the selected listbox item should move to the next item in the listbox. Click the cmd button again and the selected entry in the listbox should move to the next one.
Any help?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Move ListBox Item Up Or Down
Just wanted to make a small contribution to the forum. I looked around for this but didn't find anything really to my liking, so here's my version...
Code:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Move Selected listbox item up or down
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
const UP as integer = -1
const DOWN as integer = 1
Private Sub btnUp_Click()
If Me.lstDisplayCols.ListCount > 1 Then
Call MoveListItem(UP, Me.lstDisplayCols)
End If
End Sub
Private Sub btnDown_Click()
If Me.lstDisplayCols.ListCount > 1 Then
Call MoveListItem(DOWN, Me.lstDisplayCols)
End If
End Sub
Private Sub MoveListItem(ByVal intDirection As Integer, _
ByRef lstListBox As ListBox)
Dim intNewPosition As Integer
Dim strTemp As String
intNewPosition = lstListBox.ListIndex + intDirection
strTemp = lstListBox.List(intNewPosition)
If intNewPosition > -1 _
And intNewPosition < lstListBox.ListCount Then
'Swap listbox items
lstListBox.List(intNewPosition) = lstListBox.Text
lstListBox.List(intNewPosition - intDirection) = strTemp
lstListBox.Selected(intNewPosition) = True
End If
End Sub
the lstDisplayCols listbox is a list of selected columns to be displayed for a search result list. Just put the name of your list box there...
Move Item In The Listbox
How to move Item from the first index to second index one by one until last index. I have select the item. I want to move it down,just change the position. Code below does not works
Code:
For c = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(c) = True Then
Dim idx As Integer
idx = ListBox1.ListIndex
If ListBox1.ListIndex > 0 Then
ListBox1.ListIndex = idx - 1
End If
End If
Next
Move Item Inside Listbox (up And Down)
Hey, anyone with a simple code for moving items up or down in a lsitbox?
I mean if you have the items 1 - 5 in a listbox,and you would like
the item5 to become item2, then you simply click item5, hold button and drop where item2 is and then we get a list that looks like this:
NEW: ----- ORGINAL:
item1 ------ item1
item5 ------ item2
item2 ------ item3
item3 ------ item4
item4 ------ item5
Do you understand what i want? lets say its equal to winamp's behavior, for example...
Please help! PS: keep the code as simple as possible!
Move TextBox To Listbox Item Position
I have a list box with checkboxes., with say 10 items in the list.
I need to edit the item contained on a particular list box item. ie....I click on the check box in item 3.
Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Text1.Move X, Y
End Sub
This does move the text box to the 3rd line of the list box
but not the horizontal position.
I would like to get the text box directly over the list box item., so i can type in the altered info and then place this data in the list box (ie replace)
Appreciate any ideas of how to do this
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!
ListBox - Move List Item To Place In List
I have a list box with several items. I am trying to make a button that when the user selects an item in the list box, they can click on the button which will move the item up one in the list box:
So if my list looked like this:
ONE
TWO
THREE
FOUR
FIVE
and the user selected FOUR and clicked the button the list would look like this:
ONE
TWO
FOUR
THREE
FIVE
Does anyone know how to do this?
Thanks,
M
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
How To Move An Item In A Listview
I have a listview in report mode. I would like to be able to move one of the items to the top of the list and push all the others down. The index property is read only unforunatly although I can still Add new threads to the top and push all the indexes down. Do I just have to use .Add and .Remove or am I missing the .Move method?
Move Item In List
how do you move an item up or down in a listbox???
thnx,
squirrelly1
Move A Item In A List Box
If I forget to put an item in a list box. Can I put it in and move it where it needs to be.
Thank you for your help
I would like to move it with the mouse
Locking Item Move .. Need Help ..
Hello,
i writing a code for 2 picture boxs .. one inside one .. and its move with mouse move when draging it ..
my problem is i want to lock the inside image into the big frame picture box ..
this is my code
Code:Private Sub inside_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbLeftButton Then
xx = x
yy = y
inside.MousePointer = vbSizeAll
End If
End Sub
----------------------------
Private Sub inside_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
With inside
If Button = vbLeftButton Then
.Left = (.Left - xx) + x
.Top = (.Top - yy) + y
End If
End With
End Sub
----------------------------
Private Sub inside_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
inside.MousePointer = vbNormal
End Sub
i tried to check the top and left for inside image .. if thay are -1 .. makes them 0 and exit the mouse move sub ..
but its not working good .. i dont know why
any one have a good solutions .. ?
Thanks in advanced
Move Item In List?
Hi guys!
I have a listbox which is populated by the user with pre-defined items. What i want to do is add two buttons
that allows the user to move the selected item up or down in the list. I have the below code (move down)
which seems to be on the right track, but it moves the selected item to the bottom of the list. I want it to go
just one step down, and the item under it one step up. Does anyone have any suggestions? And how would
i edit the code for the "move up" button?
Code:
Private Sub Command17_Click()
Dim x As Integer
For x = List2.ListCount - 1 To 0 Step -1
If List2.Selected(x) Then
List2.AddItem (List2.List(List2.ListIndex))
List2.RemoveItem (List2.ListIndex)
End If
Next
End Sub
Cheers!
Maverick
Edited by - Maverick2004 on 2/5/2005 12:51:27 AM
How To Move Up Or Down Item In The Listview
Hi,
Does anybody know how to resort the order in the listview? I want to select one item and click "Up" to let it move up, or vice versa.
In addition, the MultiSelected property of the listview is seted to True. If the user select multiple items and click "Up" or "Down", how can I know? I cannot find any property like selcount can let me know if the user select multiple items. I do not want to use a loop to check the Selected property of each listitems.How can I do?
Thanks in advance. :-)
Michi
Move Listview Item?
I have a listview (report mode) that I use to display a database. I then have a search option for that listview. When I do a search I want all the items that match to be placed at the top of the listview and higlighted (selected)! I can get the highlighting with no problem, I just cant figure out how the re-index the items? So something like:
listview.listitems(someNumber).index = 1
... but that doesnt work.
Any help is greatly appreciated, thanks!
Listview Move Selected Item Up Or Down
hi ,...
i would like to know how can i move a selected item in the listview up or down ?!
i tried :
Code:
listview1.selecteditem.index=listview1.selecteditem.index-1
or
listview1.selecteditem.index =listview1.selecteditem.index +1
but this is not working !!
anyone can help me please !?
thanks in advance ..
Move Listview Item To Top Of The List
Hi, does anybody know how to move a Listview item to the top of the list?
I'd like to loop through the Listview and move all items that contain certain text to the top.
Move To Item In Listview By KeyPress
I have a database which i currently load into a Listview and sort when it loads. Now i'm trying to enable the user to press a key and have the listview move to that row. Just like in the windows explorer window. The sort will have to be done using the second column because the first column is numbers and the second is the name of a project. Or if there is a better way to show this info and sort it using a different type of view. Any help would be great.
Thanks,
Stan
TreeView Move Control To Selected Item
Hi All,
What i'm after is when a user selects a child i want to move and display a datepicker control to that position?
Any ideas??
thanks for any help!
b
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.
How To Move Listview Item Blue Highlight While Looping Within It?
Hi all.I got this listview and i am looping within it but how to make the listview hightlight move each time i loop within its item. Now i don't see any highlight at all!!
:
2 Code:
Private Sub Command2_Click()
Dim i As Long
For i = 1 To ListView1.ListItems.Count
txtURL = ListView1.ListItems(i).Text
'ListView1.SelectedItem(i) = True
txtURL = ListView1.ListItems(i)
Dim completeurl As String
completeurl = "http://localhost/script.php?s=" & txtURL.Text
ListView1.ListItems(i).SubItems(2) = Inet1.OpenURL(completeurl, icString)
End Sub
Quick Questions.
ok a couple of questions :-)
1) Is they a key ascii list anywhere?
2) Whats the best way to design AI for my monsterS?
thanks
2 Quick Questions
hey guys just a couple of questions.
1. whats the deal with Visual Basic Hex? I'm creating an application and i want to change the back colour to something other then their default colours but everytime i use the normal hex values, say from a program such as photoshop, it doesn't end up being the same colour. I may pick a really bright red from photoshop and try to make my label's backcolour that colour and it comes out blue?
2. also is there a way to make part of a label/text box/list box a certain colour. For instance.
this is red text.
So basically i want maybe 1 word to be red and the remaining words to be black or another colour.
Cheers
Two Quick Questions
Heyyyy So i have two quick questions. Ill get right into them.
1) When i put a label on a program, the selected color goes over the image. Is there any way i can make the label transparent?
2) I want the user to click on a certain command button, and then a browser will open with the appropriate web page.
Any help would be appreciated, although I would rather be told what code I should type, to make it work
Chris
Quick Questions
OK, I have a couple of things to ask.
1. How do you get characters entered into a textbox to appear only as *'s i.e. in a password field?
2. How do I create a menu bar that will:
Close the program
Display a particular form
Display a txt help file
Amateur VB user.
All help much appreciated.
Quick Questions
Hi guys!
I am a beginner in VB ..
I have some questions about VB. They should be easy for someone who knows the language.
If someone could fly ofer them, that would help me alot!
Thanks,
Phil
Number of parameters that Subroutine/Function may have?
Do the following have return values? If so, how many?
Form, Subroutine, Function, Event
For what/When the breakpoint in the debugger is used?
Where can you find controls used for data manipulation?
2 Quick Questions
Question #1
I have a VB script that I run everyday at work. It takes data from 8 workbooks and combines it all into a single workbook. It then saves it in a specific location. I would like for the file name to have the current date at the end of it (i.e. "Docx Image Problems 12-11-03.xls"). How would I go about doing this? I know that you can return todays date in excel by using the formula =Today(), but how do I tell it to combine "Docx Image Problems " & =Today()?
Question #2
Also, I am trying to write a VB script that makes a random number, and based upon what number it returns, it makes the background of an object on the userform 1 of 4 different pictures that I have saved on the computer. The object is image1, but I tried the following:
image1.picture = "c:documents and settingsjoeymy documentsmy picturespicture1.jpg"
but this doesn't work.....
2 Quick Questions
How can I limit a text box to only one character? I only want my users entering 1, 2 or 3, not 22 or 4627 etc.
How can I make my form so it can't be resized or maximised but it can but minimized?
I greatly appreciate any help
Quick Questions
Code:
Dim j As Integer
For j = 0 To 7
If chkTopping(j).Value = 1 Then pizza1(j) = Checked
If pizza1(j).Value = Checked Then
pizza1(j).Enabled = False
Next
End If
how do i get J to multiply by .20 if it is checked (value =1) for the cost of the topping on a pizza?
thanks
Quick Questions
How would i code the following in VB?
1 - I need my form to close after the clicks the "accept" button. and then open the next form.
2 - I need it so that values in the form have to be inputted - they cannot be left blank
3 - I need to increment default values in my form
4 - I need to write items to a file and add to records that already exist
Thabks for any help u can give
Quick Questions.
Hi all,
If have made my own program, this program has a members list in it. This members list is loaded from an access database to a DBgrid. It works fine only thing, some of the names are bigger than the length of the rows. So you see only a part of them.
I was wondering if there is an option, so that the row will automatically adjust.
2e question Im working with a calendar. When I double click, a form will open and I can write an event in it. This will then be loaded in to a database. This was the easy part, now I want to try to load the event (in the database) back to the calendar.
But Ive got now clue how?? Somebody?
1e Adjust row lenght of DBgrid?
2e Input from DB to calendar?
Any help our comments will be appreciated. Thnx in advance!
Yours truly,
Mark aka Koro
2 Quick Questions
I think they are quite easy to solve... but i can't find the solution.
1st problem:
i have a text box. I want the Program to give an error-message, if i enteranything else than a number.
ie. if i enter "3,5w" --> "this is not a number"
2nd Problem:
If i set focus on a textbox, i want the text in it so be highlighted....
thanks for your answers in advance
A Few Quick Questions
First
How do you disable the maximise/minimise/close button on the form..
second
how do i round off numbers eg
if i have a vairable called mynumber=0.434344 and i want to round it off to 0.43 how do i do that?
Some Quick Questions
I have some quick questions (I'm in my exams, and I don't have time to find out myself, sorry...)
First of all: is there a simple function to see whether a directory exists?
second: how can i show a picture (filename.jpg) selected by the user? Can I do this using the image-control, and if yes: where do I enter the filename?
and third: something about copyright: What do I have to do to copyright a program? Is just putting 'Copyrighted by blablabla' enough, or do I have to do something official too?
Thanks for helping a guy who's in the middle of his worst nightmare: exams
Few Quick Questions
I have just a few quick questions:
1. I add a BG to a form with the following method:
getclientrect(form.hwnd,aRect)
hBrush = createpatternbrush(mybgpic.handle)
fillrect(form.hdc,aRect,hbrush)
everything is alright for a while, but for some reason, sometimes, when my form refreshes, the background shifts by like 15 pixels, also does the same when I click a button sometimes
anyone have an idea of how I can fix this?
2. is there a way to ownerdraw the title bar of a form and get the states of the X, the _ and the button for drawing?
3. I want to play sounds when my button is clicked, how do I do this? I am using my own usercontrol command button, can I use this to my advantage somehow?
4. why is canada so cold, and why did I agree to some here from L.A. for christmas?..lol
thx
-CoNFuSiOuS
2 Quick Questions
Hello!
I had 2 quick questions. First of all, does the application "HH.EXE" come standard with Windows? If so, which versions does it come with that you know of.
Also, when using the Shell() command to launch HH.EXE, the app always starts minimized. How do I make it launch in "normal" view?
Thanks alot! [img]images/icons/smile.gif[/img]
<font color=red>ALPHANUMERIC</font color=red>
Quick Questions...
here goes...
1) I want to write the time in hh:mm AM/PM format...I write:
format(time(), "hh:mm")
but I can't get the AM /PM thing...what else should I add?
2) I want a simple error handler for taking in number inputs in textboxes which already have a default number in them...
I have:
if text1.text ="" then
MsgBox "Entry error"
Exit Sub
End if
if text1.text <= 0 OR text1.text >=1000 then
MsgBox "Entry Error"
Exit Sub
End if
this doesn't work...and as soon as I type a '-' sign to check for negative numbers I get an error...any ideas?
Regards,
Farooq
2 Quick Questions
1) How can i use a string manipulations (based on inputbox input) to change the label to read the input and count the spaces?
2) How can I have a command button appear after an image is clicked and text is entered into a textbox (I'm guessing this goes under form_activate, but what do i use for the image click?)
Quick DLL Questions
I'm writting a program which is using multiple DLLs. I was just wondering if I could get a better idea of what's going on. Here's some of the stuff I have figured out.
- Classes can be set to "global" and accessed between projects without being declared, like a module (very cool to have an ENUM across projects)
- Still very fast
- Definitely easier to manage with all the stuff in the background
- Turn binary compatibility on so you don't have to recompile every single project referencing the lowly DLL
What I want to know:
Apartment threading: what are the advantages and drawbacks of it? I'm using single threading because I have an "Item Grid" DLL which is called from multiple places and needs to always hold the same values.
Memory usage: Is there anything different about handle classes in DLLs (IE, can I pass them between projects and still have them cleared properly if I set all references to nothing)
Load times: Is a Dll loaded at startup of a project referencing it, or is loaded on the first call?
There wouldn't happen to be a way to show a modeless form and a modal form at the same time? (IE: show form1, show form2 modless, show form3 modal for form1, but not for form2) Do I need to use ActiveX EXEs?
|