Listview.listitem.add PROBLEM!
'load questions from selected category For I = 1 To UBound(IIndexArray.Category(SELECTED_CAT).Question) Debug.Print Questions(IIndexArray.Category(SELECTED_CAT).Question(I)).Question 'load into listview If Questions(IIndexArray.Category(SELECTED_CAT).Question(I)).Selected = True Then 'if the question is in the quiz LVquestions.ListItems.Add I, , "+ " & Questions(IIndexArray.Category(SELECTED_CAT).Question(I)).Question Else 'if the question is not in the quiz LVquestions.ListItems.Add I, , Questions(IIndexArray.Category(SELECTED_CAT).Question(I)).Question End If Next I
this is my code, the "Questions(xxxx).question" is a string when i used debug.print i get the string to print out but in the code below debug.print with the same UDT string nothing prints out into the listview.
well... sometimes text does print out the text will only print out for some strings, the condition is that the "SELECTED_CAT" variable must be 1. if that variable is greater than 1 the string doesn't print out for some reason.
i have never used listview before, but this is such a simple problem, and i am frustrated because debug.print works all of the time, but LVquestions.listitem.add only works some of the time.
please help
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Multiline Listitem In Listview
Hey guys (and girls )
I want to achieve something like this (auto-preview in Outlook) with my Listview (see attachment). How to achieve this??? How can I display multiple lines in a listview item? Anyone? Many thanks!
ListView ListItem Question
I am able to get to get this to work in the ListView_ItemCheck(Index As Integer, ByVal Item As MSComctlLib.ListItem).
Code:
SelItemdex = Janlv(Index).ListItems(Item.Index).Index
but I am not able to get this to work in the MouseUp event. Is there a way to do get the ListItem(Item.Index).Index in the MouseUp event?
Hide ListItem In ListView
Hi!
My problem is: hiding the listItem in a ListView.
unfortunately the properties: (ListItem.Height) and (ListItem.Hide) are missing!
I searched for this problem, but without good results!
Someone know some method (API, subclassing, etc...) resolutive??
Listview Selected Listitem
have problem here, I have selected listitem in my listview and then I check the check the checkbox to true to update the record only this item, then the selected item in my listview is set clear.why? I want to the selected listitem retain the selected item in the listview when I check the checkbox to true.
Code:
Private Sub CheckBox1_Click()
If CheckBox1.value = False Then
Set ListView1.SelectedItem = Nothing
End If
End Sub
Listview Listitem TAG Property && .m3u
Hey, I'm planning on actually doing this right this time for compatibility. Can someone give me an example of how to use the Listview.listitem "tag" property? I'm wanting to do this so I can save playlists in my program as m3u. Also, I know these playlists are just text files, but how are they arranged? I want to be able to create playlists that are compatible with Winamp & Mediaplayer, as well as my program. I was using my own file extension and textfile pattern, but it was only compatible with my program. Sooo........ I'm wanting to go *.m3u. Any help is extremely appreciated.
Listview Listitem Height
Is there a way to make the height of a listitem in a listview wrap? If the text in the column is too long it just sticks '...' at the end but I want it to expand the height to show the whole thing.
ListView Listitem Key Field
Has anyone ever tried using number as a listitem key?
You can't do it!
Even if the number is a string it complains.
Code:
Private Sub Command1_Click()
Dim itmx As ListItem
Dim strKey As String
strKey = CStr(22222)
Set itmx = ListView1.ListItems.Add(, strKey, "Item 1")
End Sub
Is there a way around this?
ListView: Blank ListItem
I have a ListView control and I allow the user to add listItems. When a new listItem is added I call the StartLabelEdit method. However if the users enters a blank name I want the listItem to go back into the edit label mode. I've tried calling the StartLabelEdit method from the AfterLabelEdit event but it doesn't work. How would I go about this?
(Essentially I'm just trying to prevent the user from entering a blank item name)
Thanks
-Mark
Listview Listitem Backcolor
Any way to set the BackColor of a ListItem (MS Common Controls). I have try using LVM_GETITEM with SendMessage, but no success... =(
Also I try de SetBkColor too, but need a compatible DC. ListItems have DC ??
Move ListItem From 1 ListView To Another
Hi,
I'm using 2 buttons to control the movement of ListItems from 1 ListView to
another. I would like to know how it is done.
Private Sub cmdAdd_Click()
Dim itmListItem As ListItem
Dim temp1, temp2 As String
With ListView2
Set itmListItem = ListView1.SelectedItem.ListSubItems(0)
itmListItem = ListView1.SelectedItem.ListSubItems(1)
temp1 = itmListItem.SubItems(0)
temp2 = itmListItem.SubItems(1)
End With
MsgBox "temp1 = " & temp1 & " temp2 = " & temp2
End Sub
The error message is 'Index out of bounds'. What's wrong with the above code??
Deleting A ListItem From A Listview Control
Here is my code to delete a ListItem form a Listview. How do you get all of the ListItems below the deleted Item to move up one row?
Code:
Form1.ProList.ListItems.Remove Form1.ProList.SelectedItem.Index
I tried...
Code:
Form1.ProList.Refresh
but that clears the whole list.
How Can We Change The Font For Listitem In A Listview?
I am using the Listview control's report view to show my data. For some of the rows I want to strikeout to show differenece with other rows.
Did anyone tried to change the font of individual listitems?
I can change the forecolor for a listitem, But I want to mark that as strikedout.
Thanks in advance,
Listview Checkbox Checked Listitem
hi,please help .how edit the sQL statement, if use the listview checkbox to insert data from listview checked listitem into Temp Table.
this is the current code:
Code:
For Each lstsel In ListView1.ListItems
strSQL = "Insert Into Temp (EmployeeName, EmployeeNo,Designation,Department,Shift,OvertimeDate,TimeFrom,TimeTo,Breaktime,OtRate,CategoryDay,WorkDescript,WorkDetail,othours) Values (" & _
"'" & lstsel.Text & "', " & _
"'" & lstsel.SubItems(1) & "', " & _
"'" & lstsel.SubItems(2) & "', " & _
"'" & lstsel.SubItems(3) & "', " & _
"'" & lstsel.SubItems(4) & "', " & _
IIf(lstsel.SubItems(5) <> "", "#" & Format(lstsel.SubItems(5), "dd-MMM-YYYY") & "#,", "null,") & _
IIf(lstsel.SubItems(6) <> "", "#" & lstsel.SubItems(6) & "#,", "null,") & _
IIf(lstsel.SubItems(7) <> "", "#" & lstsel.SubItems(7) & "#,", "null,") & _
IIf(lstsel.SubItems(8) <> "", "#" & lstsel.SubItems(8) & "#,", "null,") & _
"'" & lstsel.SubItems(9) & "'," & _
"'" & lstsel.SubItems(10) & "'," & _
"'" & lstsel.SubItems(11) & "'," & _
"'" & lstsel.SubItems(12) & "'," & _
"'" & lstsel.SubItems(13) & "')"
Debug.Print strSQL ' Check the value in the immediate window
conDataConnection.Execute strSQL
Next
Set conDataConnection = Nothing
thanks for help!
Edit Listview Listitem Data
hello,how to edit listview listitem data???i know datagrid can edit the data at the row.is possible listview to done this as well??
please help!Thanks!
Listview Listitem And Column Header
I have 2 listview and listbox. Listview1 have column and listitems. All the column for listview1 are appear in the listbox1. A few column header are chosen from listbox1 and show the selected column header in the listbox2.I want to show the listitems and selected column header in listview2. I have successul show the selected column header in the listview2.But I fail to show its listitems.How I can show the listitems?
Code:
'Column Header
Dim head As ColumnHeader
Dim colColumnIndexes As Collection
Dim Idx As Long
ListView2.ColumnHeaders.Clear
Set colColumnIndexes = New Collection
For Idx = 0 To List2.ListCount - 1
For Each head In ListView1.ColumnHeaders
If List2.List(Idx) = head.Text Then
Set head = ListView2.ColumnHeaders.Add()
head.Text = List2.List(Idx)
colColumnIndexes.Add head.SubItemIndex
End If
Next
Next
'listitem
Dim item As ListItem
Dim strItem As String
Dim i As Integer
For Each item In ListView1.ListItems
For Idx = 1 To colColumnIndexes.Count
If colColumnIndexes(Idx) = 0 Then
Set item = ListView2.ListItems.Add
item.Text = ListView1.ListItems(Idx)
Else
'item.ListSubItems.Add
item.ListSubItems.Add , , "h"
item.Text = ListView1.ListItems(Idx)
'item.Text = item.ListSubItems(colColumnIndexes(Idx)).Text & ""
End If
Next
Next
Print Listitem Data For Listview
I have problem here. I have listview1. How I can print the listitem data for the listview? I am no problem print out column header.
Code below doesn't works
Code:
'Print Listitems data
Dim j As Integer, iTab1 As Integer
iTab1 = 5
For j = 1 To Listview1.ListItems.Count
Printer.Print Tab(iTab1); Listview1.ListItems(j); _
Tab(iTab1); Listview1.ListItems(j).ListSubItems(i);
iTab1 = iTab1 + 20
Next
How Do I Update A Listview's Listitem At A Particular Index?
I have a listview populated with records. One of the listview headers is named 'status' and the default for that is 'not complete'. As the records are processed, I want to update the listview status field to 'Complete'. The header is index 10, but I'm stuck on how to find the row index.
Thanks.
Edit Listview Listitem Data
hello,how to edit listview listitem data???i know datagrid can edit the data at the row.is possible listview to done this as well??
please help!Thanks!
Setting ListView Items From A Temporary ListItem?
I'm having trouble doing the following:
I have a ListView called lvMine containing a ListItem whose key is "MyKey".
Code:
Dim litemTemp As ListItem
litemTemp.Text = "New Text"
litemTemp.ListSubitems.Add , "SubKey", "NewSubText"
Set lvMine("MyKey") = litemTemp
Set litemTemp = Nothing
Should it be possible to do this? Or must I do it the other way around, setting litemTemp = lvMine("MyKey") [in this case, I'd have trouble with adding the ListSubItems, because they might already exist].
Delete Listview Checked Listitem And Recordset
hi,how to delete listview checked listitem recordset.
for example:
when click the listview checked listitem to delete the recordset data.
this is the current code:
Code:
Private Sub cmdDelete_Click()
Dim rs As ADODB.Recordset
Dim conDataConnection As Connection
Dim lvwItem As ListItem
Dim strSQL As String
Set lvwItem = ListView1.SelectedItem
If Not (lvwItem Is Nothing) Then
Set conDataConnection = New Connection
conDataConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & _
"Overtime.mdb;Persist Security Info=False"
Set rs = New ADODB.Recordset
strSQL = "select * from Overtime & lvwItem.SubItems(i).Checked = True "
rs.Open strSQL error message highlight here.
ListView1.ListItems.Remove lvwItem.Index
Set lvwItem = Nothing
adoConn.Close
Set adoConn = Nothing
End If
End Sub
thanks for help.
Listview ListItem ToolTips - Icon View
I am attempting to use the Tooltip Property of a ListItem in a Listview but I notice that the property only works in Report mode. Are there any workarounds to make the tooltip work in Icon Mode?
VB Code:
Private Sub Form_Load()Dim LVI As MSComctlLib.ListItem With ListView1 .Icons = ImageList1 .View = lvwIcon With .ListItems Set LVI = .Add(, "_" & 1, "Text 1", "LargeIcon") LVI.ToolTipText = "This is a Tooltip" End With End WithEnd Sub
ListItem Unselecting When Dbl Clicking ListView Whitespace...
I've been fiddling about with this for hours now, and have to post!
I have a listview with a few items in. I want the selected listitem to remain selected if I double click within the listview area with no listitems. For example, if a user dbl clicks there by accident the listitem will becomes unselected, and they might forget which item they were going to select.
At the moment it's toggling from selected to not selected. I've checked all the events and I have no code in there that sets listitem to nothing or similar. And i have hideselection set to false.
Also, I don't want to run the DblClick event by clicking in this area...this should only execute if the listitem is hit. I've played about with hittest with little results.
The only things I'm changing are the following. Here's my SetUpListView sub...
VB Code:
With lvListView .Icons = ImageList1 .SmallIcons = ImageList2 .OLEDragMode = ccOLEDragAutomatic .OLEDropMode = ccOLEDropNone .HideSelection = False .FullRowSelect = True .LabelEdit = lvwManual .ColumnHeaders.Add , , "Name" .ColumnHeaders.Add , , "Directory" .SortOrder = lvwAscending .Sorted = True End With
TIA
Delete Listview Checked Listitem And Recordset
hi,how to delete listview checked listitem recordset.
for example:
when click the listview checked listitem to delete the recordset data.
this is the current code:
Code: Private Sub cmdDelete_Click()
Dim rs As ADODB.Recordset
Dim conDataConnection As Connection
Dim lvwItem As ListItem
Dim strSQL As String
Set lvwItem = ListView1.SelectedItem
If Not (lvwItem Is Nothing) Then
Set conDataConnection = New Connection
conDataConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & _
"Overtime.mdb;Persist Security Info=False"
Set rs = New ADODB.Recordset
strSQL = "select * from Overtime & lvwItem.SubItems(i).Checked = True "
rs.Open strSQL error message highlight here.
ListView1.ListItems.Remove lvwItem.Index
Set lvwItem = Nothing
adoConn.Close
Set adoConn = Nothing
End If
End Sub
thanks for help!
Resizing Listview Headers Basing On Lenght Of Its Listitem
Hi to all,
Is it possible to resize the ColumnHeader's width of a Listview control?
Sometimes the listitems that I add in the Listview is much longer than the
width of my column header. How can I get the size or length of the listitem so that I can then change the width of the column header?
What happens is that I need to resize the width of the column header just to be able to see the full text of the list item.
Thanks and god bless.
Show ListItem (ListView MultiLine Data) Ideas
Hi to all, I need some ideas, I have one but I'm looking for the best an faster idea.
that I'm trying to do is this: My program have the Search Section, and sends all results into a ListView, but some data is a MultiLine data, currently is showed in a sinlge line, my current idea is to show a ToolTipo box when the user selects one listitem, show the data contained in that field (MultiLine text), also someone tells me to use a Form designed as ToolTip box, then I need more ideas about how show this data.
Thanks
MSComctlLib.Listitem And Listitem
What's the difference between declaring an object as MSComctlLib.object and as object itself?
Let me clarify this with the following:
dim liListitem as ListItem
dim liListitem as MSComctlLib.ListItem
Jeremy
ListItem
I have been working on a datafile and am now at the point of sorting the data and writing it to a listbox.
My program is sorting OK but it stops at putting the sorted data into the listbox. Can someone help me please?
I have no idea how to copy the block of code so I will write out the portion that is giving me grief -
----- Sort has been accomplished --- then I go onto ----
Else
x = rsApplications.RecordCount
If x > 0 Then
While (rsApplications.EOF = False)
strListItem = re.Applications.Fields("ApplicationNumber")
For i = 1 to (15 - Len(rsApplications.Fields("ApplicationNumber")
strListItem = strListItem & " "
Next i
strListItem = re.Applications.Fields("Surname")
For i = 1 to (25 - Len(rsApplications.Fields("Surname")
strListItem = strListItem & " "
Next i
lbxData.AddItem strListItem
rsApplications.MoveNext
Wend
End If
I realise that the While.....Wend statement is obsolete but my boss wants me to use it.
Any suggestions would be appreciated.
Listitem
What wrong with this code?
Code:
Dim item As ListItem
Dim strItem As String
strItem = item.ListSubItems(colColumnIndexes(Idx)).Text
item.ListSubItems.Add , , "" & strItem
Listitem
dear all,
I have a combo drop down listing certain criteria is there a way that each criteria within the list box be of a different colour?
ListItem
Hey guys,
I am writting an app that displays a dynamically allocated listItem (view = 3-IvwReport) list using the following code:
Do Until rstParentCalls.EOF
strCallID = rstParentCalls!CALLID_HDW
Do Until Left(strCallID, 1) <> "0"
strCallID = Right(strCallID, Len(strCallID) - 1)
Loop
Set lstItem = ListView1.ListItems.Add(, , strCallID)
varTitle = rstParentCalls!CALTITL_HDW
If IsNull(varTitle) Then varTitle = ""
lstItem.SubItems(1) = varTitle
'Set lstItem = Nothing
varCI = rstParentCalls!FACLTID_HDW
If IsNull(varCI) Then varCI = ""
lstItem.SubItems(2) = varCI
varCINumber = rstParentCalls!FACLSRN_HDW
If IsNull(varCINumber) Then varCINumber = ""
lstItem.SubItems(3) = varCINumber
Set lstItem = Nothing
rstParentCalls.MoveNext
Loop
The list returns all the correct data in my 4 columns. The problem is that when you select a row you are able to edit the value in the first column. How do i make the list read only, but still be able to select a row so i can use the values in the columns do do further calculations??
Cheers...
Array To Listitem
Greetings all,
It has been some time since I have asked a question, and since arrays still kick my proverbial "butt", I figured no was the time. I have read the tutorials and still can't seem to get a handle on what they are saying.
So hopefully someone can reword it for me, in monosylables , I ain't none too smart.
In my job we get a part numbers through a number of methods. We plug those numbers into our terminal and it pulls up the data. (We are using Reflections 11.0 from WRQ Inc) Sadly it does not maintain a history. So I have created a macro that pastes the info into the appropriate position and adds it to an array.
What I am looking to do after that is populate a listbox on a form with the info from that array, so the user can go back reinput the part number if they have moved on to a new part.
I put a watch on the array and ran the macro a couple of times and the data populates the array, but when i try to populate the listbox it shows "out of context". How do I resolve that?
Appreciate the assistance
HWnd Of ListItem
Hi,
Is it possible to access the handle of a listitem from a listview control? I would have thought you could -seeing as the listitems are objects- but I can't see a way to get to it.
I have got a custom class which displays multi line tooltips and I want a different one for each item in the listview, but I need to know the hWnd of the listitems in order to do this, is it possible?
Thanks in advance.
ListItem TypeMismatch
For some reason, I am getting a "type mismatch" error with the following code. I have used this exact same code in another application with no problems and am stymied as to what the problem might be. The error occurs at the
"Set List = lvwCos.ListItems.Add(, , strCoName)" line...
after the error handler takes care of the error, I notice that the entry has been added to the listbox.
Code:
intI = 1
lvwCos.ListItems.Clear
For Each prov In m_collProv
Set prov = m_collProv(intI)
Dim List As ListItem
strCoName = prov.coName
strCoPrice = CStr(prov.price)
Set List = lvwCos.ListItems.Add(, , strCoName)
lvwCos.ListItems(intI).ListSubItems.Add , , FormatCurrency(strCoPrice, 2)
intI = intI + 1
Next prov
What on earth would cause a type mismatch error between the List and ListItem??
Thanks for your help..
Kevin Howell
How To Know Which Listitem Is Selected
Hi All,
Code:
ListView1.ColumnHeaders. _
Add , , "Parameter", ListView1.Width / 2
ListView1.ColumnHeaders. _
Add , , "Filename", ListView1.Width / 2, _
lvwColumnCenter
ListView1.View = lvwReport
Set itmX = ListView1.ListItems. _
Add(, , "PCM2_TaSi_via_chain_30u_R_meas_R1_1") ' Author.
itmX.SubItems(1) = CStr("R3_7b__1.ad3")
Set itmX = ListView1.ListItems. _
Add(, , "CRDNIX1") ' Author.
itmX.SubItems(1) = CStr("050928KH777E1601.ad3")
from the above code, i set 2 column and set 2 listitem
but listview does not have listcount feature for me to perform a loop to check which listitem is selected. as i have enabled checkbox and multiselect.
can anyone please advise me.
Strikeout ListItem
Hi
I've already searched a lot but without success. Do you know how to strikout a text of a single line or item in a listview? If you set the font property to strikeout the whole listview gets it, but I guess it should be possible to do it just for a single item.
Thanks and regards,
Xdream66
ListItem Bold
I have a LisView and want to get some lines Bold.
But I use COMCTL version 5 so that XP style can apply and thus there isn't the method ListView.ListItem.Item(i).Bold = True
I think I have to use API with SendMessage but don't know how to do it, so if someone can help me, I thank him/her immediately
Seb
ListItem Background
does anyone knows how to add a background color to listview listitem using API?
Why The Listitem Not Highlighted?
I have problem here. Why my listview items not highlighted during form loaded?I have untick the hide selection
Code:
Text1.Text = Pesttable.Fields("PEST_ID").Value & ""
Text2.Text = Pesttable.Fields("Nama Perosak").Value & ""
Text3.Text = Pesttable.Fields("Nama Sintifik").Value & ""
Text4.Text = Pesttable.Fields("Tanda serangan").Value & ""
Text5.Text = Pesttable.Fields("gambar").Value & ""
Dim i As Integer
For i = 1 To ListView1.ListItems.Count
ListView1.ListItems(i).selected = False
If ListView1.ListItems(i).Text = Pesttable.Fields("PEST_ID").Value & "" Then
ListView1.SetFocus
ListView1.ListItems(i).selected = True
ListView1.SelectedItem.EnsureVisible
End If
Next
Listitem As An Argument
Hi,
I need to pass a row from a listview to a funtion on another form. I only need to read the data and populate some textboxes on the target form but I'm having trouble passing a listitem as an argument to a function
The declaration is this:
Code:
Public Function fInsertDetails(itemX as ListItems)
And the function call is:
Code:
form1.funcInsertDetails (lv.ListItems(1))
I've tried declaring ItemX as a listitem, listitems, variant and without a type but I can't get it to work.
I'm probably going about this the wrong way so any help would be great
Thanks, Matt
Strikeout ListItem
Hi
Small and simple: How can I strikout a text of a single line or item in a listview? If you set the font property to strikeout the whole listview gets it, but I guess it should be possible to do it just for a single item.
Thanks and regards,
Xdream
ListItem Index??
I have:
VB Code:
For Each liTrack In lstTracks.SubItems If liTrack.Selected = True Then object.Method(<index>, otherStuff) End IfNext
The question is, what do I replace <index> with to indicate which list item the loop is currently going through?
Listitem Add Problem
I am trying to add an image to a listview control by using the index rather than specifying a particular image I am using the code
With lvwbox(i)
.Icons = ilsIcons
lvwbox(i + 1).ListItems.Add 1
It adds an empty space but no image
thanks
Combo Listitem?
well
i have a combo box that displays folders and when you click a folder name it will show all the files in that folder in a msflex grid,
i can select a file and copy it to a another directory
heres the question:
when i copy the file to another directory i want it to create a new folder the same name as the selected one in the combobox and put the file in that insted of just the plain folder
i included the form( it has other controls on it to the show commands show the files and the load and unload copys them)
ListItem Bold
I put a listview named lst on a form and write below code
Code:
Private Sub Form_Load()
Dim lvItem As ListItem
Lst.view = 3 'lvwReport
Lst.ColumnHeaders.Add Text:="Contacts"
For i = 1 To 1000 'olAddr.AddressEntries.Count
Set lvItem = Lst.ListItems.Add(Text:="A" & i)
lvItem.Bold = True
Next
End Sub
When I run the form,every Item is bold but when I select an Item, If the length of item text is greater than 3 (example A123) the text will become A1....
I dont know how to correct it?
anyone help me?
Listitem Question. Please Help.
This code shows an import to a listview.
Code:
Private Sub ImportList_Click()
Dim StrServerName As String
Dim srvName As String
Dim x As Integer
Dim itmX As ListItem
Dim y As Boolean
srvName = InputBox("Enter the file name and path", "Server List (One server name per line)", "C:Program FilesMicrosoft Visual StudioVB98NTmultiPassservers.txt")
On Error GoTo error:
Open srvName For Input As #1
Do While Not EOF(1)
Line Input #1, StrServerName
x = 1
y = False
Do Until x = ListView.ListItems.Count + 1
Set itmX = ListView.ListItems.Item(x)
If StrServerName = itmX.Text Then
y = True
End If
x = x + 1
Loop
If y = False Then Set itmX = ListView.ListItems.Add(, , StrServerName)
Loop
Close #1
Set itmX = ListView.FindItem("Click to add server name", , , 0)
ListView.ListItems.Remove (itmX.Index)
ListView.SortOrder = lvwAscending
ListView.Sorted = True
ListView.Sorted = False
Set itmX = ListView.ListItems.Add(1, , "Click to add server name")
Exit Sub
After I have imported this info into the listview. I need to ADD a subitem to each one of the items.
I know how to add a listitem then do a subitem. I just don't know how to go back and do them after I have created all the items.
|