How To Unselect Listview Row When I Click On White Area Of Listview Under Rows?
Hi all. could any one show me how i can detect if user clicked(left and write) on white area of listview as shown in the pic. When i say white area i mean area where there is no row in listview . I want to detect click on that white area and be able to unselect row.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Hide Frame When Clicking On White Area Of Listview Where There Is No Data?
I have frame and listview1. I want to hide the frame when i click(left click or right click) on white area of listview1 where is there is no data (As shown in attched pic).could any one show me how this can be done?Thanks
Code:
Private Sub ListView1_Click()
gstrSomething = ListView1.SelectedItem.SubItems(4)
gstrSomethingElse = ListView1.SelectedItem.Text
Frame1.Visible = True
End Sub
Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim lvwItem As ListItem
If Button = vbRightButton Then
Set lvwItem = ListView1.HitTest(x, y)
If Not lvwItem Is Nothing Then
Frame1.Visible = True
lvwItem.Selected = True
PopupMenu mnuEdit
Else
Frame1.Visible = False
End If
End If
End Sub
Unselect A Listview Item?
With the listview object no matter where you click it inside it, it will either select the first item in the list or the last selected item. Is there a way to 'unselect'?
So nothing will be highlighted.
ListView - Select/Unselect All
Does anybody know why the "Check All" button might not be working? This is the code I'm using:
VB Code:
Private Sub cmdAll_Click(Index As Integer) Dim i As Integer With lvMessages.ListItems For i = 1 To .Count .Item(i).Selected = Index Next i End WithEnd Sub
Listview Item Unselect Question...
I have a listview that contains several items. I have it so that when I double click an item, it opens another form with the relevant details. However, when I click in the blank space (no items) on the listview, it still opens the highlighted item, which I don't want. What I want to do is unselect (unhighlight) all items when I click on the listview in an blank (no items) area of the listview.
Ta.
ListView; Select/unselect Items; HideSelection
I would like to create a listview with selection disabled and no item selected.
First I thought the only thing I have to do, is to set the HideSelection property to true. But this seems not to be enough. The listview comes up with the first item selected and it is still possible to select items. Does anyone know what's missing?
Then my idea was to 'unselect' the first item to get a clear list (no items selected). I have set the 'selected' property of ListView1.SelectedItem to false. This has cleared the color of the item, but the item remains framed by a thin dotted line (focused?). How can I clear this frame?
How To Completely (incl. Dotted Box) Unselect An Item Of A ListView
I've a ListView in ReportMode with MultiSelect = False.
If the user enters a number I select the appropriate item in the ListView.
If the used enters a number which is not in the ListView I'd like to
unselect the former selected item. Today I do this with
Sample_ListView.SelectedItem.Selected = False
This works but there is still a dotted box around the former selected item.
Is there a way also to hide the dotted box?
Stefan
PS: The ListView should remain the focus
Listview And White Space.
I'm not sure if this is a "known thing" but I spent a hell of a lot of time trying to find a way of identifying if an item in a listview was selected or not.
I finaly came up with this - it deletes an item from a listview on the double click event but only if you havent clicked on white space. I did see code examples that do this but use many many lines of api code. Have a look and see what you think.
Option Explicit
Public MouseX, MouseY
----------------------------------------------
Private Sub lv_DblClick()
If lv.HitTest(MouseX, MouseY) Is Nothing Then
Else
lv.ListItems.Remove (lv.SelectedItem.Index)
End If
End Sub
-------------------------------------------------
Private Sub lv_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
MouseX = x
MouseY = y
End Sub
One question - that the oppisite of Is Nothing? I have tried
Is Not Nothing and that don't work.
Everso
Selected Row Outside Listview Area
Hello,
Is there anyone who knows how to get the (with code) selected row in the internal area of a Listview control?
Thanks for any reply,
Vincent.
Visible Area Fill Of ListItems In ListView
When i am reading nearly 10,000 files from a location say MyDocuments and filling the listview , it is taking large time.
Is it possible to write code as how windows will handle like displaying the items of visible area and on scroll display the next set of data.
Thanks in Advance.
Sliding ListView Item At Top Postion In Visible Area
How to slide listView Item to a particular postion in visible area ?
CheckBoxes = Yes
View = Report
List view shows say 10 (1..10) items at a time
but after a particular events of another control, I want say 20 th
item to be cheched & selected and very important
to be visible in that ListView visible area.
Any thoughts ...
Listview With About 10,000 Rows
Hey everyone,
I was just wondering if there was a way to load a listview with about 10,000 rows from a database any faster then the normal way of ADO OpenForwardOnly? Currently it is taking about 20 seconds to load the listview with all these records. That's not bad I guess but I would like it to be faster. I have indexed everything I possibly know in my SQL Server 2000 database.
Just some more info: I am not updating the listview on the screen until I finish populating it (otherwise it would take years to fill! - a hint for those who didn't know that) and I'm not updating the rows, just looking at them.
Any ideas?
Thanks,
Greg
Different Color Of Rows In ListView
Hello!
On my form I have ListView that shows data from my database.
Is it possible that, in that ListView each row would be different color depending on value of some field?
I.E.
I would like that all the rows with value 1 in first column would be red, with value 2 blue....
Do I have any chanches to do that?
Listview And Highlighting Rows
can some one please help, I'm using the following code to highlight a row in Listview, unfortunatly it's highlighting the first colomn in a group of 2, what I require is to be able to highlight just the second colomn
Set Form1.ListView1.SelectedItem = Form1.ListView1.ListItems(x)
Form1.ListView1.SelectedItem.EnsureVisible
Form1.ListView1.SelectedItem.ForeColor = vbBlue
Form1.ListView1.SelectedItem.Bold = True
How To Move Rows In A Listview?
Is there an easier way of moving rows of data in a listview control?
right now this is what im doing:
(changed it)
Code:
x = Queue.SelectedItem.index - 1
Dim t(3) As String
t(0) = Queue.ListItems.Item(x).Text
t(1) = Queue.ListItems.Item(x).SubItems(1)
t(2) = Queue.ListItems.Item(x).SubItems(2)
t(3) = Queue.ListItems.Item(x).SubItems(3)
Queue.ListItems.Item(x).Text = Queue.SelectedItem
Queue.ListItems.Item(x).SubItems(1) = Queue.SelectedItem.SubItems(1)
Queue.ListItems.Item(x).SubItems(2) = Queue.SelectedItem.SubItems(2)
Queue.ListItems.Item(x).SubItems(3) = Queue.SelectedItem.SubItems(3)
Queue.ListItems.Item(x + 1).Text = t(0)
Queue.ListItems.Item(x + 1).SubItems(1) = t(1)
Queue.ListItems.Item(x + 1).SubItems(2) = t(2)
Queue.ListItems.Item(x + 1).SubItems(3) = t(3)
Queue.Refresh
Queue.ListItems.Item(x).Selected = True
basically what im doing is you have rows of data, and you can move each row up and down to where you want it .. . but it would be a lot of code if i had 20 subitems...
Disabling Rows In A Listview
Hi
Is there is a way that I can disable rows in a Listview?.
I want to do this:
For example:
I add 5 items to a listview then I have a buttom "cmdPrint" to print those Items, if I click "Print", I want to disable the 5 item and the same time i want to add new items and if I click print the new Item need to be disable too.
This is to prevent that if I print an "Order" the users can modified the items.
I'll appreciate you help,
Elvis Cabral
Editing Rows In A ListView
Is it possible to manually edit any columns in a ListView besides the first one? No matter where I click, when I start to type the first column is the one that changes.
If it's possible could you please explain how? Thanks.
Remove Listview Rows
I've been trying to remove rows from a listview I've produced. However the results are odd... The first remove works but when trying again it removes the wrong row. I've printed and used a messagebox to make sure that the value of the row highlighted is correct and it is...
Anyway heres what I've done:
Code:
Private Sub mnuRemove_Click()
Dim ToRemove As Integer
ToRemove = lvMain.SelectedItem
lvMain.ListItems.Remove (ToRemove)
End Sub
Probably something easy but any help appreciated. Thanks
Hightlight All ListView Rows
How can I select and highlight all items in a ListView?
I've try
Private Sub cmdLoanReturn_Click()
Dim i As Integer
For i = 1 To lvloanReturn.ListItems.Count
lvloanReturn.SelectedItem(i).Selected = True
' lvloanReturn.SelectedItem.Checked = True
Next
End Sub
Add Icons To Listview Rows
Is it possible for each row to have a column with a picture in it?Mine are going to be pretty small, itd be a nice picture to add in each column. Note: i dont want a new control..ive done to much code to change that now
ListView BackColor In Different Rows
Hello people,
Who know, how can add to ListView Control BackColor not for all component, but only for different Rows and different color in what I need to add
(with VB6)?
I find that it's possible add with API sendmesage funkction from kernel32.dll, but it's only add different color for evry seccond row.
Thank's
P.S. Sorry for my bad English:]
How To Add Multiple Rows In A ListView
This is the code I am using to add information to the ListView, how do I get the text to be placed on multiple rows? Right now the code populates the ListView on one single row until it is forced onto another row. Thanks in advance for any help.
Dim j%, k%
Dim l As ListItem
'Add the ListView ColumnHeaders
For j = 1 To 2
ListView1.ColumnHeaders.Add , , _
"Column " & CStr(j), 1000
Next
For j = 1 To 2
'Add a ListItem
Set l = _
ListView1.ListItems.Add(, , "Item " & CStr(j))
Next
Listview Selected Rows
how can i get the selected rows details from a listview??
some example codes with comments pls....
i will be grateful
Coloured Listview Rows
How can I change the background colours of the rows in a list view. I don't want them all the same colour though, the colour will depend on the data in the row. I only seem to be able to change the forecolour property of the first element in the row.
Thanks
Mark
Shading Rows Of Listview
Is there anyway to shade the row of a listview with a different colors? I have a listview I'd like to fill with employees...Each can have one of 3 different types of status. I'd like to color code the status. so when I load the listview depending on what status they have the row would have a specific background color to the status.
Thanks
Keith
ListView - Different Colored Rows
I would normally be able to locate this with a Search, but since it is disabled at the moment, I must make this request.
A while back, I saw some posts regarding setting different rows of a ListView control to different backcolors (and forecolors). I believe Aaron Young posted a solution for this using an API (but I could be mistaken).
Anyway, if anyone has this code, I'd greatly appreciate it!
TIA,
Bruce
Removing Few Rows From Listview Using VB6
Hi All Great and Small,
Need your help again. I am trying to remove a few row items from ListView control where the checkbox have been checked. As per my sample script below, the system generated these 2 error messages. Please help me.
Error Message:
1. Control's collection has been modified
2. For Loop not initialised
Here is my sample script (screen dump attached)
dim itmx as listitem
With ListSelected
For Each itmx In .ListItems
If .ListItems(itmx.Index).Checked = True Then
.ListItems.Remove (itmx.Index)
End If
Next
End With
Thanks.
Have a good day,
cheers,
Lennie
Edited by - AbbydonKrafts on 11/14/2006 6:58:49 PM
Tracking Rows In ListView
Hi - my question deals with adding items to the ListItems object in the ListView control. The problem occurs when tagging a database ID with each Row/ListItem.
The problem is that the ListView object wants the value to be unique. However in my app, the same database ID can be associated with multiple rows.
That's it! Thanks for any help.
Selecting Rows In A Listview
I want to be able to select each row in a listview and display them one at a time. Here's a sample of the code
ItemNum = Lv1.ListItems.Count ' This could be more than 1
for inum = 1 to ItemNum
strEvent = Lv1.ListItems.Item(inum)
Lv1.SelectedItem = strEvent
for num = 1 to 4
txtEventInfo.Item(num).Text = Lv1.SelectedItem.SubItems(num)
next num
ItemOne = txtEventInfo.Item(1).Text
ItemTwo = txtEventInfo.Item(2).Text
ItemThree = txtEventInfo.Item(3).Text
ItemFour = txtEventInfo.Item(4).Text
next inum
I can print out row one with all the items but I can't get to row two.
Any help would be appreciated.
Mike@work
Single-click Vs. Double-click On Listview
Hey gang, can you help me on this one?
In my listview, if the user clicks an item, I basically don't want to do anything (the item that they clicked will be the current "SelectedItem" which can be used when needed).
However, if they double-click an item, I want that to act as a "shortcut" to an Update command.
Bottom line - how do I manage both single and double-click events?
Listview - Swap Columns With Rows
(Not sure if this should be in the general or in the user interface forum)
I have a listview that I am displaying data in. Everything is working fine, other than I had a request to modify it so the column headers are on the left side (where the rows normally would be) and the rows on top (running top to bottom).
I can't seem to find a way to swap, rotate, or otherwise make this work. Has anyone ever tried this or know of a way to do it?
Thanks.
Change Backcolor Of Certain Listview Rows
Hi, I'd like to change the backcolor of Listview rows when a certain condition is met. So far I've only been able to find two ways, subclassing or changing the color of all even/uneven items.
I found this code, but it changes the backcolor of every even item. I've played around with it, but I can't get it to work the way I want.
Does anybody know how to modify this code, so I can give it an index number to change the backcolor of specific rows, like this?
Code:
Private Sub AltLVBackground(lv As ListView, _
Index As Long, ByVal RowColor As OLE_COLOR)
Code:
Private Sub AltLVBackground(lv As ListView, _
ByVal BackColorOne As OLE_COLOR, _
ByVal BackColorTwo As OLE_COLOR)
Dim lH As Long
Dim lSM As Byte
Dim picAlt As PictureBox
With lv
If .View = lvwReport And .ListItems.Count Then
Set picAlt = Me.Controls.Add("VB.PictureBox", "picAlt")
lSM = .Parent.ScaleMode
.Parent.ScaleMode = vbTwips
.PictureAlignment = lvwTile
lH = .ListItems(1).Height
With picAlt
.BackColor = BackColorOne
.AutoRedraw = True
.Height = lH * 2
.BorderStyle = 0
.Width = 10 * Screen.TwipsPerPixelX
picAlt.Line (0, lH)-(.ScaleWidth, lH * 2), BackColorTwo, BF
Set lv.Picture = .Image
End With
Set picAlt = Nothing
Me.Controls.Remove "picAlt"
lv.Parent.ScaleMode = lSM
End If
End With
End Sub
Private Sub Form_Load()
Dim x As Long
With lv.ListItems
For x = 1 To 50
.Add(, , "ListItem " & x).ListSubItems.Add , , "ListSubItem " & x
Next
End With
AltLVBackground lv, vbWhite, &HC0FFFF
End Sub
Error '480' When Coloring Listview Rows
Hi, I'm coloring Listview rows with unchecked items, which generally works fine, but when too many rows are colored I get a "Can't create AutoRedraw image (Error 480)".
I know it has something to do with AutoRedraw creating a memory copy, but I'm wondering if there's a workaround? Setting AutoRedraw to 'False' disables the coloring.
For me the error occurs with 499 items when using the code below.
vb Code:
Option Explicit Private Sub Form_Load()Dim i As Long SetupPicBox For i = 1 To 50 '<-- Increase this number and eventually a "Can't create AutoRedraw image (Error 480)" will occur ListView1.ListItems.Add , , "Just some testing" ListView1.ListItems(i).SubItems(1) = "more testing" ListView1.ListItems(i).SubItems(2) = "even more testing" ListView1.ListItems(i).SubItems(3) = "testing testing" If IsEven(i / 2) Then ListView1.ListItems(i).Checked = True Next i ColorListView End Sub Private Function IsEven(ByVal i As Long) As Boolean IsEven = Not -(i And 1)End Function Private Sub SetupPicBox() picBg.BackColor = ListView1.BackColor picBg.ScaleMode = vbTwips picBg.BorderStyle = vbBSNone picBg.AutoRedraw = True picBg.Visible = FalseEnd Sub Private Sub ColorListView()Dim i As Long picBg.Width = Screen.Width picBg.Height = ListView1.ListItems(1).Height * (ListView1.ListItems.Count) picBg.ScaleHeight = ListView1.ListItems.Count picBg.ScaleWidth = 1 picBg.DrawWidth = 1 picBg.Cls For i = 1 To ListView1.ListItems.Count If ListView1.ListItems(i).Checked = False Then picBg.Line (0, i - 1)-(1, i), &HC0FFFF, BF End If Next ListView1.Picture = picBg.Image End Sub
Dynamically Creating Rows In Listview
Hi all,
am creating an application where i have to give a provision to enter data in a list view and the entered row will be stored in database. How can i achieve this. how can i dynamically create new rows in listview.
any help can be appreciated
saj
Keeping Track Of Listview Rows
Hello, I'm downloading some files simultaneously and I'm showing the percentage done in the second column. When a download is finished I want to remove the row from the Listview.
The problem is that when Picture2 (with index number 2) is removed from the Listview, Picture3 moves one up and gets index number 2. But I'm using index number 3 to continuously update the progress of Picture3 and now suddenly I have to use index number 2 to update the progress of Picture3.
ListView1.ListItems(2).SubItems(1) = Percentage & "%"
I'm not really sure how to solve this. It's probably something very easy I haven't thought about..
Change Height Of Rows In Listview
Hi
I have a listview control set to Report and would like to know if there a way i can change the Height of each row without increasing the font size?
Thanks
Listview - Multiple Selected Rows Help
Hi, I'm working on a way for a user to group up items in a database. I'm using a listview, but I was wondering if there might be a better way.. I'll probably run into many problems along the way, and here's the first one (besides trying to find a way to get the number of selected items without looping)..
This is what I want to happen..
I populated a listview with the contents of a database, Desc, Asset Number, Quantity.. I want the user to be able to select a groups of rows and combine them into one record in the database.. One thing is that the user can only select items either above or below a currently selected item.. What I tried doing was in the ItemClick event, try to test if the row above or the row below have been selected.. Problem is, when I use the CTRL key to select more than one row, the listview.SelectedItem.Index property is not valid.. How can I find the index of newly select row when other rows have already been selected?
Thanks
John
Copy Multiple Rows From One Listview To Another
Currently I have a program form that has 2 listviews on it. It is able to copy one item from one listview to another. Now the users want to be able to copy several at once from one listview and paste into the other at point/row where they click/selected. I hope that makes sense.
Here is what I have currently for the single copy/paste type of process:
[CODE]Private Sub cmdSetSeqNum_Click()
Dim ItmX As ListItem
On Error GoTo ERR_HNDL
Set ItmX = lvwSampleMap.SelectedItem
If (ItmX Is Nothing) Then Exit Sub
ItmX.EnsureVisible
ItmX = lvwInstrPositions.SelectedItem
CheckChanges
Exit Sub
ERR_HNDL:
StandardErrorOutput Err
End Sub
[/CODE]
Any help/suggestions would be greatly appreciated and thanks in advance.
~Becky
|