Listview Problem; Listview.selecteditem
So, I have a listview that displays a series of things, and refreshes every 10 seconds. (By refresh, I mean it clears itself and re-fills all info from a database)
When it refreshes, I want to check and see if any message was selected before the refresh, and if so, select it again.
Code: 'select nothing...GRRRRrr For i = 1 To frmQuickCom.lstMessages.ListItems.Count frmQuickCom.lstMessages.ListItems(i).Selected = False Next
'Reselect the originally selected item 'if there are Select Case SelText 'this is passed in when this sub is called' Case "" 'if there are no messages, don't select any If frmQuickCom.lstMessages.ListItems.Count > 0 Then frmQuickCom.lstMessages.SelectedItem.Selected = False End If Case Else 'something was selected For i = 1 To frmQuickCom.lstMessages.ListItems.Count If SelText = frmQuickCom.lstMessages.ListItems(i).Text Then Set frmQuickCom.lstMessages.SelectedItem = _ frmQuickCom.lstMessages.ListItems(i) frmQuickCom.rtfMessage.Text = strMsgTransfer frmQuickCom.lstMessages.SelectedItem.EnsureVisible End If Next 'move the window to show the selected item End Select
So here's the problem -- even if I set selecteditem.selected = false, Selecteditem still has a value. Is there anyway to actually clear that value entirely? (The reason why I ask -- if a message is deleted, it is leaving the last added item (in the next refresh) as the 'selected' item, even though it gets set to false. If I try to key off of the selecteditem value, then, it returns something.)
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Listview - Selecteditem
how to replace the value of selected item in listview?
i hv this column header and value
SEL___SQ___ PR___PRSQ
_S_____1____1732____1
i want to replace the value of "S" in SEL column to "D"
i use this
lvwList.SelectedItem.SubItems(1) = "D"
but each time it will replace the data in the "SQ" column
i try to replace the index from "1" to "0" but invalid.
any idea?
Listview Selecteditem
Other than using a For Loop to find out if there is a selected row in a listview:
Code:
If lvReport.ListItems.count > 0 Then
Dim lst As ListItem, i As Integer
For i = 1 To lvReport.ListItems.count
Set lst = lvReport.ListItems(i)
If lst.Selected = True Then
lst.Selected = False
Set lvReport.SelectedItem = Nothing
End If
Next i
End If
Is there a quicker way than this?
ListView.selectedItem
When using the code to for a user to select a row of data from a listview to be removed. I do not get the required results. Once the user has selected a row, it should search the listview for the selected row, find it, then search the recordset for match, then delete the record from recordset and listview.
Code:
If Not LVProf(listviewNo).SelectedItem Is Nothing Then
For i = 1 To LVProf(listviewNo).ListItems.Count
If LVProf(listviewNo).ListItems(i).Text = LVProf(listviewNo).SelectedItem Then
With Myrecordset(listviewNo + 1)
.MoveFirst
While Not .EOF
MsgBox (LVProf(listviewNo).ListItems(i).Text & " " & LVProf(listviewNo).ListItems(i).SubItems(1))
If LVProf(listviewNo).ListItems(i).Text = LVProf(listviewNo).SelectedItem And LVProf(listviewNo).ListItems(i).Text = .Fields(0) And LVProf(listviewNo).ListItems(i).SubItems(1) = .Fields(1) Then
.Delete
Exit For
End If
.MoveNext
Wend
End With
LVProf(listviewNo).ListItems.Remove (i)
End If
Next i
Else
MsgBox ("You have not selected a record to remove")
End If
When I select the last record on the listview control, the line of code (If LVProf(listviewNo).ListItems(i).Text = LVProf(listviewNo).SelectedItem Then
) always picks out the first record in the listview. Why would this be?
ListView.SelectedItem
Put the code in the keyup event, not the key down. When the key is down the previous selected item in the listview will still have focus. Only after the key is up does the newly highlighted item come into reference.
Hope this helps!
ListView.Selecteditem
Is there a way to simulate a selection (let's say to the third item on the
list) and cause the highlight to appear?
Any ideas welcomed and appreciated. Thanks!
Listview SelectedItem Question
I have an array of ListView boxes on a form. I want to know if the user clicks in one of the ListView boxes where there is no Text. This does not work. Anyone have the answer?
Code:
If Jantxt(xx).SelectedItem.Text = "" Then
Form4.Show
End If
SelectedItem.Bold Listview
Hi,
Im trying to set the font of a selected item to normal when unselected. I hope you understand what I'm trying to say.
In the Click_Event of the Listview I wrote:
Code:
Select Case Listview1.selectedItem
Case "blablabla"
Listview2.font.bold = false
listview2.selectedItem.bold = True
Case "blabla"
Listview2.font.bold = false
Listview2.selectedItem.bold = true
...............
Nothing is happening except for becoming bold when selected.
Someone with some experience with this feature?
Thanks in advance.
(by the way: the vbcode tags don't work anymore)
***RESOLVED***ListView SelectedItem
I have a ListView containing two records (rows). My ListView is populated with a main item in the first column and ListSubItems in the adjacent columns.
If the user selects a member of the ListView and clicks a button, I would like a message box to appear stating the contents of the ListView main item for the specific record currently selected.
I know how to do this for ListSubItems:
MsgBox ListView1.SelectedItem.ListSubItems(1)
I just need to know how to do this for the main item now.
thx
Listview SelectedItem Highlight
I got a listview with various other controls on a form.
After I lose focus on the listview, I want to keep whatever was selected Highlighted, not sure how to do this
ListView Show Selecteditem
ListView1.SelectedItem.EnsureVisible will scroll the listview until the selected item is visible. But, what if I have multiselect enabled and I have like 10 selected items from 100 in the listview? With each command button click, I need to display next selected item in the list. Of course, I can create a global value and check which selected item was already shown, and just play it of from there, but is there an easier way? Thanks.
Change Listview.selecteditem Thru Code?
I have a popupmenu on my listview, and that only fires when a person right clicks. I want it so that if the user right clicks it will still highlight the line they clicked on...possible?
ListView, Removing Listiem Highlighting When SelectedItem Is Nothing
Ok, you have a listview with some rows...
If you have FullRowSelect = True and HideSelection = False then when you select a row, it gets highlighted. We can all see this.
Now, if I use:
VB Code:
Set ListView1.SelectedItem = Nothing
Then no item is selected, BUT the row that was previously highlighted stays highlighted!
Any ideas?
Woka
Here's the prject I am working on.
It's only supposed to be for screen shots at the moment, so my code is a tad rough and not 100% structured yet I appologise.
basically when you click on a GREY CD image I want the listview to DE-select the row...any ideas?
[Read] Need Help With Custom Scrollbars On A Listview Control! Or Skinning Listview..
I have been searching for weeks now to find a way to use a custom scrollbar to scroll a listview...
Like this:
Now I use an alternating BG function on my listview and I am currently using the ensurevisible method of scrolling a listview...
Is there a better way?
I will post some example projects if needed...
But how would I use a custom scrollbar on a listview control
Thanks for helping
2 ListView Questions. 1 About Selecting Records. 2 About Adjusting Listview Box Size.
Hi,
I'm changing some of my programs to use a ListView instead of a ListBox.
1. On selecting a record how do I pass the info from the fifth column to another Sub? (I have .FullRowSelect = True)
2. I'm dynamically adjusting the column widths to the maximum length of the data going into the column. Is there a way to dynamically adjust the width of the listview box itself to be the sum of the column widths?
Thanks,
Al.
How To Compare 2 Listviews And Copy Listview Content To Another Listview?
Hi all. I am filling a listview with xml data as shown in code beleow. I am calling this part using timer.What i want at the end of this code to compare listview1 with listview2. If they are diffrent or if listview2 is empty then i copy content of listview1 to listview 2.Otherwise do nothing. could any one show me how i can make such compare an copy?Thanks
1 Code:
Dim objDoc As MSXML2.DOMDocument
Dim objNodelist As IXMLDOMNodeList
Dim objNode As IXMLDOMNode
Dim lvwItem As ListItem
'load the xml document
Set objDoc = New MSXML2.DOMDocument
objDoc.async = False
objDoc.Load "http://localhost/data.php"
'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(5) = objNode.selectSingleNode("totalvotes").Text
Next objNode
''Here i want to compare listview1 with listview2. If it is empty or diffrent if fill it
otherwise i do nothing.
Set lvwItem = Nothing
Set objNodelist = Nothing
Set objDoc = Nothing
Moving A Listview Item And Its Subitems To A New Listview
Hey Guys,
Having a bit of trouble. I am attemping to move a selected item and its subitems from one listview to another. I have no problem getting the contents of the first column, but I can't seem to get the subitems over.
Example: I have this in the first listview:
Code:
|Item |Quanity|Price |PQ |
Bananas 2 $.50 $1.00
Then when I try to move that whole row to the other listview I can only seem to get this:
Code:
|Item |Quanity|Price |PQ |
Bananas
No subitems . Any links or help would be appreciated.
Regards,
Max_Power
Listview.Add No Longer Recognize? Listview.mscomctllib Instead?
So I hadn't done some Vbasic coding in like a month. Then i go to edit my code and find the debugger throwing an error on my listview.add.
I delete the .add and hit the . key to see what the supported methods are and it only shows "MSComctlLib" as my option. But then it throws an error when i try to select that. How did this happen and more importantly how do I get back to normal listview methods?
Listview; Getting Data (populate Listview) From 2 Tables??
hi!
im using a listview of my program..
where i need popluate the it with data coming from 2 tables, (table 1 and table 2); and where one of the entities in both table are the same...
for instance;
table 1 = stud_genInfo
table 2 = stuf_Offenses
both has the entity= stud_Number..
in which i need to show the stud number in my listview..
how can set (code) to show the Stud_no.?? confused:
can anyone help me with this one?? pls i need ur help, badly...
i would appreciate all the help/suggestions anyone would give..
mauve
-----
btw, this is a snip of my code:
strToday = Format (now, "mmddyyy")
With rsSearch
.Open "SELECT * FROM GenIndo, Offenses WHERE Schedule.Date_Today = '" & strToday & " ' And Schedule.Stud_No =CheckUp.Stud_No", CN, adOpenStatic, adLockPessimistic
If .RecordCount <= 0 Then
lvwSchedule.ListItems.Clear
Else
lvwSchedule.ListItems.Clear
.MoveFirst
Do Until .EOF
Set xlist_item = lvwSchedule.ListItems.Add(, , !Stud_NO) ' this is the line(part) where VB highlights the error
xlist_item.ListSubItems.Add , , (UCase(!Last_Name) & ", " & !First_Name & " " & !Middle_Name)
xlist_item.ListSubItems.Add , , (!Offense)
xlist_item.ListSubItems.Add , , (!Offense_Type)
xlist_item.ListSubItems.Add , , (!Offense_No)
.MoveNext
Loop
End If
.Close
End With
Set rsSearch = Nothing
-------
thank u so much...:
Combine 2 Listview Items Into One Listview
I have 2 listviews that have a different listitems.
ex.
LV 1 LV 2
1. A 1. B
2. C 2. D
3. E 3. F
Is there a way to combine the 2 to another listview so that they all look like this with out doubles of matching items?
ex.
LV 3
1. A
2. C
3. E
4. D
5. E
6. F
Drag Listview, Target Is The Same Listview
Hello,
I would like to let the user set a priority on listviewitems by multiple selecting them and dragging them to the correct priority.
So.. I would like to drag and drop a multiple selection and the target is the same listview.
I hope this makes sence.
patrick.
Combine 2 Listview Items Into One Listview
I have 2 listviews that have a different listitems.
ex.
________________
LV 1 l LV 2 l
l l
1. A l 1. B l
2. C l 2. D l
3. E l 3. F l
_______l_________l
Is there a way to combine the 2 to another listview so that they all look like this with out doubles of matching items?
ex.
_______
LV 1 l
1. A l
2. C l
3. E l
4. D l
5. E l
6. F l
_______l
Drag And Drop From Listview To Another Listview
Hey Guys,
I've think i've tried everything but cant get it to work. I can get it to work to a text box or a list bow but not to another Listview!!
Anyone know how to drag the contents of a listview to another listview??
b
Listview Finditem, Result At Top Of Listview
Hello,
I use the function FindItem in order to find what I want. I have one problem : I would like that the result is at the top of the listview, it means, the first visible, not the first of the complete list.
Thanks you
ListView -Drag&Drop- ListView
Does anybody have an example about how to do a Drag & Drop of items between two ListViews? Any help would be welcome. Thanks, in advance.
How To Filter One ListView To Another ListView<Resolved> I Think
I have a listView that displays the content of an Access Database. So far so good. Now I want to the line items in another ListView based on the content of one field. That's where I get lost. I can check the value of desired field IF that line is highlighted, but How do I cycle thru all the Items to send to my second listview?
Any suggestions?
Sample list:
Author Title Describe In(this is a checkbox) Out(this is a checkbox)
kf4iis How to Fix It How to Fix Things (Unchecked) (Checked)
crude example I know.
Any suggestions would be helpful
Charles
Edited by - kf4iis on 6/2/2004 6:27:40 PM
Select From Listview To Listview
Hello all,
This is what I need:
I have one listbox that is populated on load. When a user selects a record, then I would like all records assoc. with that record to show up in another listview.
eg. User selects BOB from the listview1 and this will populate listview2 with all of bob's other misc info.
By the way, listview2's column headers are set at form load.
Listview To Listview Copy
I'm looking for some sample code that shows you how to copy selected contents from one listview control to another listview control. Can anyone help me out with that?
Thanks much.
ListView Selection Based On Second ListView Selection
I have 2 ListView controls.
ListView1 contains a number of items, for one of which a SubItem contains the number 1.
ListView2 contains 10 items, containing Subitems with numbers 1 to 10.
If I select the item in ListView1, of which the SubItem contains the number 1, I would like the ListView2 selection to change to that which contains the SubItem with the number 1 as well.
thx
How To Get Items From Other Program's Listview To My Program's Listview
Hi, I am not sure how to continue with the coding. that is all i can think of. I am trying to get the list of the items from listview to my program's listview. But can't get any items out of them. What do i have to do ?,. please someone help me. =(
the list view is like this
Image Itemname1
Image Itemname2
Image Itemname3
etc....
ief& = FindWindow("IEFrame", "MSN Chat - Chat Room - Microsoft Internet Explorer")
msn& = FindWindowEx(ief&, 0&, "Shell DocObject View", vbNullString)
ies& = FindWindowEx(msn&, 0&, "Internet Explorer_Server", vbNullString)
ies2& = FindWindowEx(ies&, 0&, "#32770", vbNullString)
a& = FindWindowEx(ies2&, 0&, "atl:37242c08", vbNullString)
b& = FindWindowEx(a&, 0&, "atl:msnchatlistview4", vbNullString)
c& = FindWindowEx(a&, b&, "atl:msnchatlistview4", vbNullString)
d& = FindWindowEx(c&, 0&, "SysHeader32", vbNullString)
Getting Mad With LstView.SelectedItem
Hi all!
I'm trying to select an item from my ListView. I tried:
Code:
ListView1.ListItems.Item(1).Selected = True
It doesn't work to me.
Code:
Set ListView1.SelectedItem = ListView1.ListItems(1)
Neither does it.
Ideas??
Datacombo.SelectedItem
Hi.
I can't seem to fix my problem, and was wondering if anyone could help. I am trying to retrieve the correct text value from an ADO bound datacombo by setting it's SelectedItem index to the recordset value of the previously chosen value. Say my value (rs!dept) is 5, with the text being "Indexing". when I try to set datacombo1.selecteditem = rs!dept, I get a 424 (Object Required) error. Is there any way to set the datacombo back to "Indexing" without creating a new recordset and querying it for the text value i need?
TreeView.SelectedItem.Next
Im having a problem, here's an example of the treeview:
Main Category
...Category 1
......File 1
......File 2
......Sub Category 1
..........Sub File 1
...Category 2
......File 3
......File 4
When i delete Category 1, i need to go through every entry between that category and the next category.
So to do this, you would use .Next
Thatwill return the next category name in that Column. But when i do Next.Index, it returns the very next line's index... So if Category 1 is index 50, then it returns 51..
Anybdoy know a way around this?
Lv.selecteditem & Subitems?
Im wondering here...How would i tell which row and which item a user selected? Would it be best to place picture boxes behind my columns so that they are invisible, and check which one the mouse is over at the time of the click?
Set ListView1.SelectedItem
I did a search in the MSDN : Here
They gave something like that :
VB Code:
Set ListView1.SelectedItem = ListView1.ListItems(2)
But why that do not work ?
Treeview Selecteditem
hi
there´s a way to set the selecteditem by code instead mouse click in run time?
some like:
set treeview1.selecteditem = "keyname"
????
i need to redraw the treeview in some situations, but i would like that the selecteditem was the same before redraw.
thanks
DBList SelectedItem
In VB5, this property returns a variant. If populated, I believe it is an array of bytes (TypeName returns Byte()), but I'm not sure how to test this. IsEmpty() doesn't work.
If I use Ubound() on it when I've selected something, I get three values (not sure what they indicate; does anyone know???). But if I don't, SelectedItem is a null string.
I've elected to use BoundText, but I'd still like to understand this.
TIA.
|