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




Index Of Last Item Added To A Combo Box


I know there's a way to read the index of the last item added to a combo box. Does anyone remember?thanx/good luck,adam




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Index Of Newly Added Item In Sorted Listview
I need to find the index number of the item last added to a listview.
I can use listcount, except if the user clicks on the column header
and sorts the list, then the next item added could be listed in the
middle of the items already in the list. So .ListCount would not work
in that situation. So if I have a listview with items #1,#2,#3, and
I add an item which is placed in between #1 and #2, how can I find out it's spot in the list????

Any ideas or direction would be very helpful.

Click Item In Listview Then Show That Item In Combo As Index = 0
Hi guys,

I have a listview (lvwUserPunchedOut) that is populated with records in a database (persons first name in one column and last name in the second column), what I am looking to do is if I select a persons name by clicking on it in the listview on frmMain, and then bring up frmSearchCriteria, i would like to show that selected name in the combobox as default (cboEmployee.ListIndex = 0) on frmSearchCriteria (the combobox is sorted = True and is also populated with first name and last name of the person)

How would this be done? Hope I make sense. Thanks in advance.

Determining The Length Of The Longest Item Being Added To A Combo Box
I have no idea if this is possible, but here is what I'm told needs to be done.

I have to add three items to a combo box (ListViews or third party components are not an option).

The second item is the name of an insurance company, which can vary in length.

As the combo is being populated, I need to determine the length of the item, and add the third item one space over. If the next item that is being loaded is the same length or shorter, I need the third item to be loaded in the exact same spot as it was the last time. If the next item being loaded is longer than any previous item, I need to add one to its length and MOVE everything that has been previous loaded over to that location so that at the end of the combo load, the third item lines up in a nice, neat, little row.

I've told my boss that I don't believe this is possible but I want to double check with you guys.

(PS: I have no sample code to post 'cause I wouldn't even know where to start on this one. )

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.

Cannot Get Index Of Item In Combo
i have added each printer on the system to a combo box:

for each prn in printers
cboPrinter.additem prn.devicename
next

then set the first item to be systems default printer:

cboPrinter.Text = Printer.DeviceName

When i click a button to get the index of the item in the dropdown box:
For i = 0 To cboPrinter.ListCount - 1
MsgBox cboPrinter.List(i) & cboPrinter.ListIndex
Next

it says the listindex for each item is -1. Shouldn't it be 1 to how many printers there are in the list ie:

printer 1 = index 1
printer 2 = index 2

etc?

Or is that method of setting the default printer wrong and interfering?

thanks for your time.

How Can We Know The Index Of An Item Data Value In A DropDownList Combo In VB6
I would like to receive help on the following described issue.

In my form I have a dropdown list combobox, which is populated with 'additem' and 'Itemdata' methods. during program execution, I know only a particular value stored in the itemdata. I dont know index and listed values.
I want to get the index corresponding to the Itemdata Value. How can i get that?

Thanking everybody,
sreeraj

Index Last Added Image
I am using a DHTMLedit control in ma VB6 app.
I have a 'add picture' button and I add a picture in my DHTMLedit document as follows

DHTMLedit1.execCommand DECMD_IMAGE,OLECMDEXECOPT_PROMPTUSER


This works but now i want to get the image index so i can change the attributes.
As soon as I add the image, the added image hasn't got the focus, so or i set focus on the image (but how) it has no id/name and what's is index?

I tried something like
tk = DHTMLEdit1.DOM.images(DHTMLEdit1.DOM.images.Length-1).Src

But the problem with length -1 is that this gives only the last positioned index (on bottom of the page) on the page and not the last added one.
So i have to use something else, any ideas?




 

Edited by - lvermeersch on 9/8/2005 6:22:40 AM

Show Last Item Added In Listview.
Hello there! I just wanted to ask if there's any way to display or go to the last item added in a listview. I have this attendance system and it's working out fine. But they want to see that during scanning, their name should be displayed as it's added to the listview. There will be no user intervention by the way as the computer is inside a cabinet with just the barcode scanner the interact with.

Sort Vba Listbox After New Item Added
I have a listbox which I want to sort after a new item has beed added. My code is as follows:


Code:
With Name
i = .ListIndex
i = i + 1
.AddItem , i
s = InputBox("Please enter name: ")
If s = "" Then
.RemoveItem i
Else
.List(i, 0) = s

.List(i, 1) = s
End If
End With

Dim vaItems As Variant
Dim p As Long, q As Long
Dim vTemp As Variant

vaItems = Me.Name.List
For p = LBound(vaItems, 1) To UBound(vaItems, 1) - 1
For q = p + 1 To UBound(vaItems, 1)
If vaItems(p, 0) > vaItems(q, 0) Then
vTemp = vaItems(p, 0)
vaItems(p, 0) = vaItems(q, 0)
vaItems(q, 0) = vTemp
End If
Next q
Next p

'Clear the listbox
Me.Name.Clear

For p = LBound(vaItems, 1) To UBound(vaItems, 1)
Me.TeamCode.AddItem vaItems(p, 0)
Next p


End Sub

The code works fine until I add the sort code (also found on this forum, I think by Timbo?), it causes a type mismatch error at:
'For p = LBound(vaItems, 1) To UBound(vaItems, 1) - 1'

Any idea what I have done wrong?

Listview Item Added Event
I was just wondering if there was a way of triggering an event when an item is added to a ListView control.
I am making a server browsing app, and due to the design of it, I need to trigger an event when a new server gets added to the list (so that I can add ping values, etc.)
Would subclassing the control be suitable for this requirement? I'd prefer it if there was another way, because I'm not 100% sure how to subclass a control as I've never had to before, and also because it might either slow down the app considerably or cause it to crash. It queries about 30-50 servers per second, so the method used would need to be as fast as possible.

Thanks.

How To Print Just Added Item To The Listview
I have a Listview when I add item then I press the buttom cmdsave I save the data to the database and the sametime I print all items to the printer

This how I print


Code:


Open "COM1" For Output As #1

Print #1, "VB6 RESTAURANT"
Print #1, "======================================"

For i = 1 To ListView1.ListItems.count
Line = (ListView1.ListItems(i).ListSubItems("Qty") & _
(ListView1.ListItems(i).ListSubItems("Description")))

Print #1, Line
Next i

Print #1, "======================================"





I save the items to the database and print the "Order" if the Order is still open, the user can add new item and can see those items that he save it before but, but here is my question.

How can I Just print the new item that I add to the listview without print the others.

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

Showing The Latest Item Added To A ListBox
Hi,
I have a listbox to which I'm adding new items. The listbox is high enough to show 6 items without having to use the scroll bar.

When the listbox gets more than 6 items, I want it to scroll automatically to the bottom of the list to show the latest items without having user to use the scroll bar.
How do I do this?

Thanks.

Is It Possible To Subclass A Menu Item Added To Another Appliction?
I've tried numerous times, and failed, to gain control of a menu subitem added to a menu in an existing application.

I am trying to create an addon to a program that does not have an exported object model to play with.. I have been able to create a menu item with subitems under it but have been unsuccessful in subclassing the wndproc for these menu items to control them when clicked on.

I am currently using Win2k and VB6 sp3.  Does anyone know of a way to do this?

(I heard of problems w/ setwindowlong replacing windowprocs in 2000 unless the software is part of the same process thread.  I even Tried attaching my process to the other applications process thread, however unsuccessfully).

Thanks in advance.

--NipsMG

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

How To Play Wave Sound When An Item Is Added To Listview?
Could any one show me how i can play a wave sound only once when new row is added to listview? The code beleow is used to populate listview.




1 Code:
Private Sub PopulateListview()
Dim objDoc As MSXML2.DOMDocument
Dim objNodelist As IXMLDOMNodeList
Dim objNode As IXMLDOMNode
Dim lvwItem As ListItem


   If objDocCopy Is Nothing Then Exit Sub
    Set objDoc = objDocCopy

       
    'add all the song nodes into a  nodelist
    Set objNodelist = objDoc.selectNodes("//song")
   
   'Clear the listview
    ListView1.ListItems.Clear

    'Loop through each song node and add to the list view
    For Each objNode In objNodelist
        Set lvwItem = ListView1.ListItems.Add(, , objNode.selectSingleNode("artist").Text)
        lvwItem.SubItems(1) = objNode.selectSingleNode("name").Text
        lvwItem.SubItems(2) = objNode.selectSingleNode("image").Text
        lvwItem.SubItems(3) = objNode.selectSingleNode("rating").Text
        'lvwItem.SubItems(4) = objNode.selectSingleNode("songid").Text
        lvwItem.SubItems(4) = objNode.selectSingleNode("totalvotes").Text
        lvwItem.SubItems(5) = objNode.selectSingleNode("page").Text
        lvwItem.SubItems(6) = objNode.selectSingleNode("referrer").Text
        lvwItem.SubItems(7) = objNode.selectSingleNode("pageWindowName").Text
    Next objNode

    Set lvwItem = Nothing
    Set objNodelist = Nothing
   Set objDoc = Nothing
End Sub

ListBox: Automatically Scroll So Last Item Added Is Shown At Bottom
Maybe listbox is not the best way to do this, but here's what I want:

Program creates log records to display to user what tasks the program is performing. The log records are displayed in chronological order as they are written. Whenever a new record is written, it will be the last one visible within the list box. If the list box can show 4 records, when record 5 is written, you'll see records 2-5 in the list box, when record 6 is written you'll see, records, 3-6 in the list box, etc.

I used SendKeys like so ('li' is the list box index):

If li Mod PageSize = 0 Then
SendKeys "{PGDN}"
End If

But the problem is that if the user interacts with the application at all, this gets messed up. Also, if the app is minimized, then SendKeys affects whatever app the user is currently working with.

In searching the listbox threads I saw a post where the ListBox.SetFocus was done before the SendKeys, but that seems like it that would also interfere if the user had switched to a different app.

Ideas?


Jim

How To Add SubMenus Or Item In A Menu(popup) In Run Time , Need To Added More In List
Hi,

In my project, in a grid control, i list all AreaName, when the user click one Area and Right Click, then ther will be a menu called 'List All Equipment Under This Area', So how can i load All The Equipment Under this menu, when the User selected Area and click 'List All Equipment Under This Area'. I can select them through query , but how i will load them in the Menu. Through code how to do add them in the Menu, may be there will be more the 100 Equipments to be added some times and more over that these Equipments should be added when the user clicks the 'List All Equipment Under This Area', is it possible. Kindly if there is any sample or linkk give me.

Thankyou,
Chock.

Activate ListBox Dbl_Click Event Without Clicking On An Added Item.
Is it possiple to activate the listbox double_click event without clicking on an added item. i.e. if the user dbl clicks anywhere in the listbox. I can only get the event if I dbl click on an added item.

How To Add SubMenus Or Item In A Menu (popup) In Run Time , Need To Added More In The List
Hi,

   In my project, in a grid control, i list all AreaName, when the user click one Area and Right Click, then ther will be a menu called 'List All Equipment Under This Area', So how can i load All The Equipment Under this menu, when the User selected Area and click 'List All Equipment Under This Area'. I can select them through query , but how i will load them in the Menu. Through code how to do add them in the Menu, may be there will be more the 100 Equipments to be added some times and more over that these Equipments should be added when the user clicks the 'List All Equipment Under This Area', is it possible. Kindly if there is any sample or linkk give me.

Thankyou,
Chock.

Combo Box Need To Be Added ...
Dear Friends,

Could you plz have a look at my project and do the needful.

First I need code for add button since it is not working.

I need the combo box to be filled automatically with the name field from the database.

When I select a name from combo box the following fields should be filled in

txtName

txtCity

so I dont need to enter a "txtName" and "txtCity" text boxes to enter when adding the data.

Please help.

user3377

Saving Text Added To Combo Box
i am trying to figure out how to save text entered in my combo box. users can input items but when they close the program it doesn't save the info they entered.

i'm a newbie sorry if this is a simple one.

this is an example of what ll i have:

Private Sub Command7_Click()
Combo1.AddItem Combo1
End Sub

Private Sub Command8_Click()
Combo1.RemoveItem Combo1.ListIndex
End Sub

Private Sub Form_Load()

End Sub

How To Stop Data To Be Added Into Combo Box
hi

in my database for my combo box i want the user to only be able to select from the list and and not be able to add in the field.

my combo box details come from a different table because i got a job activities table, and a products table, and they are both linked so when the product is added in the produts table the combo box of the product in the job activity is automatically updated, so my problem is that i dont want anything to be added into the job activities table on product so if a new products is to be added they have to add it into the products table, and if they do try i want an error message to be displayed

can anyone help me with this one please

thanks x

Get The Item Index
I have a UserControl that uses two classes the individual class and a collection class, how I can implement into the Individual class to get te Index number into the collection class ???

like ListItem and ListItems

Example:


Dim LstItem as ListItem

Set LstItem = ListView1.ListItems(1)

'I want this
Msgbox LstItem.Index

'This prints 1


Thanks !!

Tab Index To Get To Next Item
I have set up the tabindex on my form to go to the correct place when the tab button is pressed. I need it to select the text in the text box when the tab button is pressed. Right now it goes to the begining of the text box but does not select the information in the text box. Any ideas would be appreciated.

Recieving Item By Index
hi,

with this piece of code im trying to receive a certain record by stating the ID in the table.

i have a variable which stores the ID, intStaffID. but im not sure where to place it in the following code.

this is on the click event of an mshflexgrid. it stored the ID, then i want it to select the staff record with that ID...


Code:
If Not IsNull(myRecSet.Fields("shiftstartMon").Value) Then 'Validation for null value
strGetMonStart = myRecSet.Fields.Item("ShiftStartMon").Value 'Get data from field
txtShiftStartMon.Text = strGetMonStart 'Insert data to textbox
Else
txtShiftStartMon.Text = "No Shift" 'Insert "No Shift" If value = Null
End If

thanks,

sam

Index Of Selected Item
Anybody out there know a quick way for me to find out the index of a selected item within a listview?

I know I could loop through it easy enough to find the index but is there another way of doing it?

Api To Get The Index Of An Item In A ComboBox
Hi,

Is there any APi that give us the index of comboBox item? For instance, I would say the item as a tring and then the APi would tell me is index in the combo?

PS: I need this to get the index of a itemdata.

Thank you

Sergio Oliveira

How To Get The Item Index In Wmp.dll Control
hi, please if somebody can tell me how can i get the item index of a media item in a playlist in this control (wmpsdk 10 or 9)

i want to know the item index of the current media playing (maybe the same media is twice or more in a playlist in diferent position (index), so i can use isidentical)

thank you

Please Help - Error 457 - Index Already Associated With This Item.
Simple form used to input 2 strings (key & value), to be stored in Dictionary (dictLocations)which is instantiated in Module1. Works fine until user clicks yes in message box, then get Error 457 (duplicate key)???

Thanks for anyone's help!


private Sub cmdOK_Click()
Dim key as string, val as string
dictLocations.Add tbLocNo, tbLocDesc
If MsgBox("Add Another Location?", vbYesNo) = vbYes then

me.Hide
tbLocNo = ""
tbLocDesc = ""
me.Show

else

me.Hide
End If
Unload.me
End Sub

Getting The Index Of A Collection Item.
Is it possible to get the Index of a collection item if you know the key it was added under?

example:

dim Mycol as new collection
Mycol.Add "keyboard","bob"
Mycol.Add "monitor","peter"
Mycol.Add "desk","joe"

I want to know that "monitor" is the second item in the list by using the key "peter" can this be done?

Jean-Guy

Making The First Combo Box Item Always The Selected Item
Hi.

I have a combo box with a Dropdown list Style and which is invoked several times in different parts of my form. How can I make the first item in this combo box the selected item or the default item everytime I select it? Currently, what's happening is that the last item that I selected becomes the selected item the next time the combo box is invoked. Thanks for any suggestions in advance!

DB Form Wizard - Added ADO Combo Box, Need It To Update Text Fields
I used the data form wizard and used an ADO control. I added and filled a combo box, but the code I previously used to update the text fields bound to the recordset using DAO did not work.

For DAO I had:


Code:
Private Sub cboCompany_Change()
datCustomer.Recordset.Bookmark = cboCompany.SelectedItem
End Sub
All I need the ADO combo box to do is when a company is selected, all of the text fields bound to the recordset will be updated with the selected recordset.

Thanks guys.

Getting Item Data Index With Listbox Value
I'm trying to get the itemdata int value from a listbox using the listbox text value. For example:

populate the listbox using a query:
rst = select id, value from table

While (Not (rs.EOF))
lstbox.AddItem rst!value
lstbox.ItemData(lstbox.ListCount - 1) = rst![id]
rstSiteID.MoveNext
Wend

So what i want to do is get the "id" value from a selected
"value" in a listbox.

Any help would be appreciated.

>> How To Determinate The Index Of An Item In Array
Hi! I have 2 arrays called "id()" and "name()" and when I assign a string value to the name array, I assign also an id.
so... i want to get the index by specifing the item in the "name" array like this:

1st item= "a" index = 0
2nd item = "b" index = 1

and if i want a function that determinate the index of an item by specifing the text in this case


thanks


simons

Remove Item Index Number 1
Hello, I am making a list of people that connect to the chat room of there IP in a list called listPeople. But i want to remove the ip when they disconnect. I know the code is something like this, but can you help me get it right?

listPeople.removeitem(UserIP, [1])

UserIP being a String of thier remoteIP
and
1 being the index

also will the same code work with listpeople.additem?

Thanks in advance/.

Using The Index Number Of An Item In An Array
Another easy one (sorry!) :-)

I am trying to use the number of the items in my array so that, say:

If ArrayOne (Item number is 1 or 2 of array) Then

Do this

If ArrayOne (Item number is 3 or 4 of array) Then

Do this

Etc...

Is it possible?
Thanks for reading, Chloe x

Retrive Index Of Item In Listview?
How the hell do i retrive the index of an Item in a listview control?!
Sometimes I just hate this cnotrol...its too complicated...

Anyone?

Calling An Item By Its Index In A Type
Let's say I have a Type like this:


VB Code:
Public Type userinfo()Name As StringPassword As StringEnd Type


Now, if I want to access the item "Name", I need to say

VB Code:
Dim i As userinfoMsgbox i.Name

Can't I access an item by its position or index like this:

VB Code:
Dim i As userinfoMsgbox i.Index(0)'The above code is not right but it gives you the idea.  

?

Locate Index Of Certain List Item?
Hi,

I have a list box with the text values of:

A
B
C

How can I quickly find the index number of B?

Thanks,

Dan

Index Of Selected List Item
I have a combo box, style 1, where users can enter items into the list by typing it then hitting enter. I want the user to be able to select one of the list items already entered and be able to delete it by pressing the delete key.
How can I delete the selected record?

Selecting An Item From A DataCombo Using The Index ID
Good morning all.  I have a DataCombo control (not to be confused with ComboBox) which is populated with data.  I am wondering how I can display the Description (ListField) text by referencing the Index ID (BoundColumn) i.e.

I have three entries in the DataCombo
0. Red
1. Green
2. Blue

I want to reference which is to be shown by the number, but I want the string to be displayed.

How I Could Get The Index Adding An Item To A List?
The solution could be this :
List1.AddItem ("" , Index)
but, it does not work!!!
First i have a compiler error (expected = )...
Num = List1.AddItem ("" , Index) Solves the problem, but if index is diferent than 0 this doesnot work.

I want to create a dinamic list of errors and capture his identification.
How i could do this?

How To Delete A LisBox Item Withou Use The Index?
Hi VB programers:

I'd like to know how to delete a listbox item without use the item index?

-------------------
Ex:

ExtSpa.RemoveItem (Var ?)

---------------------

Thank you.

Get Index Number Of Selected Item Combobox
I want to get the index value of the selected item in a combobox.

dim i as int
i = combo1.index (this doesn't work, duh)

i cant think of a way? (stupid )
ty

Find An Item Index In A Collection Without Looping?
Is it possible to find the index of an item in a collection by its text without looping?

Finding The Index Of An Item In An Array (Resolved)
Hi,

Is it possible to select an item in an array by sending the index number to it. I am wondering if this can be to automatically without having to type the index number in?

TIA

Nightwalker

Setting Listview Item To An Index Number
Ive been using the following to set the selected item in my listview:


VB Code:
MatchFiles.SelectedItem = MatchFiles.ListItems(OldName)


which sets the current item equal to that contained in 'OldName'.

Is there a command similar to set the selected item to an index number? So i could set row 7 to selected? Thanks

Finding The Index Of A Control Array Item
Hey im really new with VB,

I have a control array in my project and i need to find out which element in the array the user clicked on.

Just to clarify, say theres 5 elements in the array

option(1), option(2), option(3), option(4), option (5)

when the user clicks on any of these i need to assign the number in the index, (1,2,3,4 or 5) to a variable. Thanks a lot!

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