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




Listbox To Always Display Last Item


I've got a list box that gets a number of items added to it. How do I ensure the latest item added each time will have focus?

Thanks.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Listbox To Always Display Last Item
I've got a list box that gets a number of items added to it. How do I ensure the latest item added each time will have focus?

Thanks.


EDIT: Got some help and found my answer.
list1.listindex = list1.itemcount - 1

Display Listbox Item That The Mouse Is Over
I've been messing around with the mouse move thing for a Listbox for that last hour and I can't figure out how to get what the mouse is over, as it moves around the listbox, to be displayed in the status panel at the bottom of my form.

How To Scroll A Listbox To Display Selected Item
My problem is as follows:

I have a listbox and my program selects a certain item based on coded algorithms. The listbox contains many more items than can be displayed at one time, so I have to use the scroll bar to search through the content of the listbox.

When my program selects an item in a listbox that is not currently in the view frame, I have to find the item by manually scrolling up or down until I can see it.

I would like my listbox to scroll automatically so that the selected item is in view.

I have not found a way to find out which items are displayed, or even to programmatically make the list scroll.

Any suggestion?

Thanks in advance

Right Click Item Is ListBox And Display Options
HI,

I am using the ListBox in VB6. In this listbox, I am displaying all of my information in a sorted order. At the bottom of the Listbox, I display a summary of the specific items from above in the list box. Want I am looking to do is from the Summary at the end of the Listbox, I want to right click on an item, and have the option to go to where this item is located from the sorted information above.

Basically, I wanted to see if if possible to right click on an item and have options (i.e cut, paste, goto). I saw something about a ContextMenu??? Is this what I need to look at, or is this for vbnet?

Thanks

How To Display Total Item In Listbox Automatically?
hi all .could any one show me how i can display total nubmer of items in list box automatically when listbox get loaded with data.Thanks

Display Listbox Item's Description In A Textbox
Hi all, I'm new to VB and this is my question:

I have a list box where the user select an item from the list box, and the description of the item will be display in a text box.
Different item will display different description in the same text box. How can I do this?

I've been trying by using this code:

VB Code:
Private Sub List1_Click()    Select Case List1.ListIndex       Case 0:           Text1.Text = "A Description"       Case 1:           Text1.Text = "B Description"       Case 2:           Text1.Text = "C Description"        End SelectEnd Sub


But the description is very long (more than hundreds words), I tried to store it in an access database, but failed because text size too large. Is it possible to save the description in a .txt file and load the description from that .txt file into the text box?

Thanks in advance!

Select Item From Listbox, Display Related Fields In Corresponding Textboxes
hey,

i have a form that the user types in a person's lastname and hits the find button, it queries the database then displays the matching records (the first and lastname) in a listbox. by the way i have the itemdata property holding my EmployeeID field. When the user double clicks on one of the names in the listbox it requeries the database by the EmployeeID field...and thats as far as i can get. i want it to then display the employee's phone number, address, ect. in textboxes on another form. i can't seem to find the correct code to do that. i know textbox.Text = list1.list(listindex) will display, in my case the first and last name of the selected record in a textbox...but i want the related fields to populate the other textboxes. i've searched everywhere, i found a lot of posts like this one but nothing seemed relevant. i'm using DAO...heres my code:


Code:
Private Sub emp2editlist_DblClick()
Set EmpDB = OpenDatabase("C:Documents and SettingsDatabase.mdb")
Set EmpRS = EmpDB.OpenRecordset("Select * from EmpInfo where 'EmployeeID' ='" & emp2editlist.ItemData(emp2editlist.ListIndex) & "'")

If emp2editlist.List(emp2editlist.ListIndex) > "" Then

frmEditEmpInfo.Show

frmEditEmpInfo.txtfname2.Text = ?
frmEditEmpInfo.txtlname2.Text =
frmEditEmpInfo.txtphone2.Text =
frmEditEmpInfo.txtaddress2.Text =
frmEditEmpInfo.txtcity2.Text =
frmEditEmpInfo.txtstate2.Text =
frmEditEmpInfo.txtzip2.Text =
frmEditEmpInfo.txtssn2.Text =
frmEditEmpInfo.txtdh2.Text =
frmEditEmpInfo.txtposition2.Text =
End If
any help is much appreciated, thanks

Coding A Listbox To Display Matching Variable Array Item In Label Control
Can some one help me on this one. I am just a beginner with VB so it may seem easy for some of you. I have a listbox with 50 States listed in it. I also have a Variable Array (1 to 50) with the names of the state capitals declared in the general declarations section of the form. Within the same form, how do I code the Variable to display the state capital in a label control based on the State selection made in the listbox. The data for both the listbox and the variable were input from a sequential file that contained 50 records of two fields each, (State and its Capital). The listbox listindex would be 0-49 and the array is 1 -50. Just a few pointers would be good. Thanks.

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

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

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.

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

I Want To Display Data In Two Columns In Listbox And Add Items In Listbox How Is It Possible In Vb 6.0
i want to display data in two columns in listbox and add items in listbox how is it possible in vb 6.0 ...?

I Want To Display Data In Two Columns In Listbox And Add Items In Listbox How Is It Possible
i want to display data in two columns in listbox and add items in listbox how is it possible ...?

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

Combo Box Display First Item
Probabably being stupid but how do you display the first item in a combo box after adding the items at present the combo is blank when the form loads...

Doesnt Display Item...... HELP!!
here's my code... it doesnt display anything..

i got 1 data in the database, the table named: appointment... and its fields is set to

[date]
september 2

[time] 10

[ampm]
PM

and if i set the system clock to 9:59 PM to test the code... after it reaches 10 PM it doesnt display anything on the textbox.. can u help me with my code...


VB Code:
Private Sub Form_Load()txtdate.Text = DateWith Me        .Left = (frmmain.ScaleWidth / 2) - .Width / 2        .Top = (frmmain.ScaleHeight / 2) - .Height / 2    End WithSkin1.ApplySkin Me.hwndEnd Sub Private Sub Timer1_Timer()DisplayHourSet rs = New Recordsetrs.Open "SELECT * FROM [appointment] WHERE [Date] LIKE '#" & txtdate.Text & "#' AND [Time] LIKE '#" & thour & "#' and [timeampm] like '#" & ampm & "#'", db, adOpenStatic, adLockOptimisticIf rs.RecordCount = 0 ThenExit SubElsetxtptname.Text = rs![Name]txtptmidname.Text = rs![middle name]txtptsurname.Text = rs![surname]txtcphone.Text = rs![cellph]txtphphone.Text = rs![homeph]txtphlocal.Text = rs![phlocalnum]txtreason.Text = rs![message]rs.CloseSet rs = NothingEnd IfEnd Sub  Sub DisplayHour()Dim thour As IntegerDim ampm As String If Format(Now, "hh") > 12 Then thour = Format(Now, "hh") - 12    Else thour = Format(Now, "hh")    End Ifampm = Format(Now, "AM/PM")End Sub

Display First Item In ComboBox...
Hello,

I am using an User Control Which was custom made..

I have added items to it however I want to be able to auto select the 2nd item in the list by defualt when the application runs.

Does anyone know how to select the 2nd item in the combobox..

The User Control which im using is in the .zip file included with this post.

Thanks

(Note: I didn't make this user control I downloaded it from the net)

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

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!

Listview Item Display Incomplete
i have a listview in my form where listview.View = 2-lvwList.
then i add in items. But the items display not in complete.

eg. the item is "10-10-2005, 00384-1005, $1,200.00". but the item in the listview display "10-10-2005, 0 ..."

how to make it display the complete sentence? Please help. Thank you.

Display Last Added Item In A Listview
What's the equivalent to a msflexgrid's toprow property for a listview?

How Do I Display A Specific Item From A Combobox
I need to know how to choose what list item is displayed in a combo box when it is not dropped down. This did not work:

statusCombo(2).topindex = statusCombo(2).newindex

I tried this because I want the newest item entered into the list to be the list item which is displayed when the control is not dropped down.

Combo Box - Display And Save Different Item
hello guyz...i've got a problem here.. i used combo box to display all the CityName in my project. Actually, I want to save CityCode to the database.
How can i link dis two item, where i display all the name of the city and at the same time, save the code of the city to the database?

thank you

Display Item From Datagrid As Label
I have created a small program for our children to keep track of their school work/assignments. I have an sql database called Schoolwork where they can enter the assignment name/date started/date completed/ due date etc, which I have displayed on my form in datagridview with a dropdown list to select the subject that they want to see (this part works well). Want I want to have happed is to have the last item (just 1 of the columns) appear as a label at the top of the form as a quick reference. EG If they have selected the subject 'Reading' I want just the title of the book that they entered last to appear as the label, eg Tom Sawyer, or if they have selected 'Maths' and the last item entered was - 12 times table - I want that to appear as the label.

Any help here appreciated.

How To Display Send Item From List
Dear guru,

here i have a server sending me a message
team,a,b

so i split the message as below

Code:

part() = split (x,",")


and then i want to display it at the list box


Code:

If part(0) = "TEAM" Then
Dim availa As String
Dim availb As String

availa = part(1)
availb = part(2)

List2.AddItem availa
List2.AddItem availb

Call List2_Click
End If

Private Sub List2_Click()

Winsock1.SendData "team," + List2.Selected
End Sub



i know it is wrong for the winsock send data, how do i select it?
another problem, the list2 did not insert into the list box, when i run it, i got nothing in the list box

Making Combobox Display The Next Item In The List.
I have a combobox that the user picks a state from. when a certain integer hits a certain point, I'd like it to move down to the next item in the combobox.

Here's my code, but it doesn't work.


Code:
Dim theState As String
theState = USAcombo.List(USAcombo.ListIndex)

If Age = 19 And Page = 52 Then
theState = USAcombo.List(USAcombo.ListIndex) + 1
End If
I need, however, not the variant value that it gives me, but rather the actual text used in the combo box. For instance, AL is USAcombo.List(0), but I don't want the number "0", I want the letters "AL" (for alabama).

Hope this makes sense, and all help is appreciated!

How Do I Get A Combo Box To Display An Item On Form Load
Excuse what may be a really simple question but I have only just started using VB

I have combo box that loads 3 values on frmload using cboUsername.AddItem

I have the box set to display as dropdown list to stop users being able to enter their own data.

At present when the form loads the combo box is blank and will only display the values when clicked on. What I would like to do is for the first value to diplay automatically when the form loads - is there a way I can do this.

Many Thanks

Urgent !Display Checked Item From The Database
Hi,
I have a problem here about checkbox. I am creating a form that requires the user to fill up a form about a product particular. The form also includes a checkbox that ask the user whether the user would like to continue to purchase the product. So instead of deleting the product record, the user is given an option to keep the record for further use.
When i check the CheckBox, it will be saved into the db but when i run the form again, the CheckBox will not show the checked mark but it is shown in the db.
How should i display it into the form? I am using Vb6.0 & Access2000
thanx in advance.

Example code:

Private Sub DisplayRecord()

txtName.Text = rsRecordset!Name
chkDiscontinued.Value = rsRecordset!Discontinued

End Sub

How To Display Subreport On Clicking Item In Report
Hi All
I am using Crystal report.

I have a report with vendors list in it. What I want is to display the sales done by vendor when the user click/selects a particular vendor name. How do i do this. I was trying to do this with sub reports.
Can somebody please suggest how to write code in crystal reports to open the sub report on click the vendor name
e,g
1 vendor1
2 vendor2
3. vendor3
4 vendor4
5 vendor5

when user clicks on vendor2 i need to display the sub report . I am passing vendor2 variable to the sub report using shared variable.
In short how to program the click event of Crystal report
thanks


Mind is faster than Wind --- Mahabharat

Listview- Display Most Recent Added Item On Top
Hi,
I have a small problem with listview sorting....coz right now, my most recent added item appears at the most bottom row. And I've this limited area of listview that can only display 4 rows. Thus, when i add more than 4 items, the rest of items does not appear on the listview immediately. So, i have to scroll the vertical bar to locate the last added item.

Wonder if VB provides a function whereby the most recent added item can be displayed at the top of the listview instead. And probably it can also get selected to show that it's the most recent item added(the next feature).

If not, any suggestions?

Thanks

To Display A Face Id In The Ribbon Item In Excel 2007.
Hi All,

We were using a menu in the previous versions of Office. To display the icon to a menu item I used face id property. Now for Office 2007 the menu's have been replaced with Ribbon.

Please let me know how I can load the icons using face id value to a ribbon item.

Thanks & Regards,
Abhi Ram.

Select Any Menu Item & Display Message In Status Bar
Helo,

I am using VB Menu and Status Bar, I want if I select any menu item, a message display in Status Bar of VB.

For example:

Click on File Menu and select New then display message in Status bar "Open new document"

I highly appreciated if u provide me code.

Nadeem

Display Item Selected After Closing Search Form
I have a form for search (frmSearch1) and a main form (frmMain). Using a flexgrid in the search form i populate the grid with the search routine.
After the search i want the user to be able to click on one of the items, then close the search form, and upon returning to the main form i want to posistion the recordset to the selected record.

What i have so far posted below...I use this code to capture the primary key(getRecNum) of the item selected.
But i don't know how to get back to the mainform and reposiition to the selected record.

Thanks,
Eldron Gill

Private Sub MSFlexGrid1_Click()
Dim getRecNum
MSFlexGrid1.Col = 0
MSFlexGrid1.Row = MSFlexGrid1.RowSel
getRecNum = MSFlexGrid1.Text
Unload Me

End Sub

Listview Ctrl Need To Display Selected Item Even When No Focus
I am using a list view control in my project. Evidently the first item is selected by default in a list view control, but it is not apparent until the control gains focus. I have a button under the control that allows the user to delete an item from the control. Problem is that if the control does not have focus, the user may not be sure what he is deleting. I am trying to dummy proof the program, because if you select an item from the control and then move focus to another control, the list view maintains the selected item index but it is not visible to the user.

**Bottom line- Is there a way to have the list view control maintain the selected row highlight even when the control loses focus?

Thanks-
Tracy

Last Item In A Listbox
A listbox normaly shows items 1 down to the maximum showable in that box despite of the value of .ListCount . How can I tell VB - after aplying the .AddItem-method - allway to show the .ListCount-item at the last line of the listbox (will say: display items [.ListCount-max. lines] to .ListCount)?

Thanks in advance!

Lightgun

For Each Item In Listbox...
Here is what im Trying to do:

Something like....

For Each Item in Listbox

MsgBox The Data of the item

Next

Its so simple, yet i havnt been able to figure it out =/

Listbox Item Taken Out
Hey, i also need to know how to take away an item from a list. so say i had lstMyList.additem myPerson.name

i would want to take away myPerson.name when i did a certain thing

does anyone know? thanks...Xtrava

Listbox Item
Is it possible to have some kind of short textstring shown with some information when you have the mousepointer over an item in a list box??

If I have the mouse of item 1 it might say "bla bla bla" and if I move it over item 2 "tada tada"

Add Item To ListBox
I'm trying to write a winsock program (but the actual problem doesn't have anything [at least I don't think] to do with Winsock, so I'm posting here). It is a LAN based IM system, and on the server side, it has a list box with connected users. What I'm trying to do is to add the user based on the index of the Winsock object, but I get an "Invalid Procedure Call or Argument" error on that line.

lstUsers.AddItem user(0), Index

user(0) is the user's name, and Index is the Index of the Winsock Object. When I comment out/take out the ", Index" part, the program rusn with no error. Where did I go wrong?

Listbox Value For An Item
I am populating a listibox with items. Is it possible to populate it like a combo in a html form?

I have a list of athlete's and when seleted I want to pull the ID for the athlete. I can already pull the text that is displayed but hoping I can add additional info like in a html combo and when selected display the other info.


VB Code:
...Do While adoRs.EOF = False            lstAvailable.AddItem adoRs.Fields.Item("ATHLETE_NAME").Value            adoRs.MoveNextLoop...


Update: Sorry, I said listview originally, I meant to say listbox.

Thanks for your help in advance.

ListBox Item
I have got a list box on a form, and I'm saving data into an Access Table like this, if 2 options are chosen, I place the first item in the field then I use a (comma), and then place the other option and so on.

Now I want to reverse it and do something like this, want to read that field and whenever it finds a comma , it should place the data in the next line. And I want to put the results in MsgBox and if I have these three items saved in the table: PS2, Newspaper, XBox...I would like them to appear in the MsgBox like This:
PS2
Newspaper
xBox

Any help on that?

Item From Listbox
Hi all,
I'm using a listbox which is containing around 100 items and the contents of listbox are changing after regular intervals. If a user selets an item from listbox, how can i get the name of the selected item?
Help me pls.
Anita.

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