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




Stop ListView Selection When Not Wanted


Wow... that's a tough topic. It's easier to explain than what it means in the subject.

I have a TreeView-ListView interfase. The problem I'm having is when I right-click over the ListView, e.g., show it's corresponding popupmenu, and select an option which would not open any new menu or something. E.g., change some values to variables, or change the apearance of the app. What happens is that the mouse (I don't know how to explain it) "keeps" on selection status, and would select all the items you hover the mouse over after this. Of course, this would end if you click anywhere or sth. But I want to avoid this "autoselection status". Does anybody know how to do it??




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Stop Listview Selection
I am trying to stop the first row in a listview being selected when the form is first loaded.
I have tried using the

Code:
Listview1.SelectedItem = Nothing

in the Form_Activate and this doesn't work.
There is no other control on the form to set the focus to.

Any ideas or workarounds?

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

Stop Arrow Keys Changing OptionButton Selection
In my application, I have a toolbar at the top, and a PictureBox taking up the rest of the screen.

The toolbar contains an array of OptionButtons, Style=Graphical.

The PictureBox displays a map.

I want the user to be able to navigate the map using the arrow keys, so I set up a keyboard hook to capture key presses, check for the arrow, and do the appropriate processing. And all was well.


However!...

Pushing the arrow keys also has the undesired effect of selecting a different tool, should the OptionButtons have the focus at the time the key is pushed.

So does anybody know of a way to stop the arrow keys from cycling through the OptionButtons?

I thought I could capture it in the KeyDown event of the optionButtons and set KeyCode = 0, but the event isn't even triggered.

Stop Listview Flickering?
Hi folks,

I am having trouble in preventing flickering while adding items to a listview.

Please help!

Stop Drag In Listview
I found this code


Code:

' REQUIRES THE MSGHOOK.DLL LIBRARY

Const WM_NOTIFY = &H4E
Const LVN_FIRST = -100&
Const LVN_BEGINDRAG = (LVN_FIRST - 9)

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As _
Any, source As Any, ByVal bytes As Long)

Private Type NMHDR
hwndFrom As Long
idFrom As Long
code As Long
End Type

Dim WithEvents FormHook As MsgHook

Private Sub Form_Load()
' start subclassing the current form
Set FormHook = New MsgHook
FormHook.StartSubclass Me

' fill the ListView1 control with data
' ... (omitted) ...
End Sub

' this event fires when the form is sent a message

Private Sub FormHook_BeforeMessage(uMsg As Long, wParam As Long, lParam As Long, _
retValue As Long, Cancel As Boolean)

' the ListView might be notifying something to its parent form
If uMsg = WM_NOTIFY Then
' copy the MNHDR structure pointed
' to by lParam to a local UDT
Dim nmh As NMHDR
CopyMemory nmh, ByVal lParam, Len(nmh)

' check whether the notification is from the ListView1 control
' and whether it's the beginning of a drag operation
If nmh.hwndFrom = ListView1.hWnd And nmh.code = LVN_BEGINDRAG Then
' yes, cancel this operation
retValue = 1
Cancel = True
End If
End If
End Sub




but I can't get it to work (I have a lisview on my form).

It craps out at:

Dim WithEvents FormHook As MsgHook

Any ideas?

Stop Listview Loading
Hi everyone!

I'm filling a listview with a lot of data. If the user gets tired, he can press a button "Cancel" which should stop the listview loading.

To do that, in the loading loop I put a flag which is continously read at every cycle, for example:

Code:
While count<MaxCount And GoOn

'fill listview
'...
count +=1
End while

' Routine for cancelling
Private sub OnBtnCancel_click (...)
    GoOn=False
end sub
 

However, while the listview is filling up, I cannot press any button because the UI is freezed. So the Cancel button is unuseful.
Usage of Listview.BeginUpdate and Listview.EndUpdate() is useless.

The only way I found to make this work is to have the listview filled by another thread... but this is of course illegal because one should have the UI thread which created the listview to handle it, and not another thread.

Does someone have an idea?

Thank you

No Selection In My Listview
hi,

i've made a listview, and i want to make sure nothing is selected when the form starts up, so my fill looks like this:

With lvShowList
.View = lvwReport
.GridLines = True
.LabelWrap = True
.FullRowSelect = True

.ColumnHeaders.Add , , "Naam"

'then here i _do_ stuff , is all ok, just fill the thing up with
'the correct data

With .ListItems
For i = 0 To UBound(arrData)
.Add , , arrData(i)
Next i
End With
Set lvShowList.SelectedItem = Nothing
End With

when i debug: selected item is set to nothing,
unfortunately, it _is_ set to the first item.
anybody's got a clue on how to _really_ set selecteditem to nothing (and make it stay that way untill a user clicked on something)

thanx,
christie

Listview - Row Selection
I am using a listview in my program with 30 rows

If i left lick on any row it gets selected, but if i right click on any row, then the row is not selected.

Ive added some code which runs when the user right clicks a row.

But now in my program the user first has to select the row he wants ie first he left clicks the row he wants and then right clicks on that row.

So is it possible to select the row whenever the user right clicks on any row in the listview.

ListView Selection
Hi

I am have a program where the user selects from a list of calls. When they double click ta new form opens displaying all the call details. If they make any changes then I refresh the data on the original form to show the new values. However, this causes the listview to display the first item in the list as the selected row.

How can I ensure the same row is being higlighted when I move back to the original form withe listview? I have tried storing the index etc but nothing seems to work.

Cheers

Listview Col Selection
I have tryed Listview.SelectedItem(0).Text

How do you get the first colume on a Listview and then more colums on the row selected

I use VB6

Listview Selection
God morning
As you can see in the attached pic, when you select a row first time it will look as pic 2, what I want is it to look as pic 1, which now only can be achieved by either click again on the same row or click on another row (as far as I know)

Can it be solved?

thanks

ListView Selection
Hi

I'm using a ListView to displays some records. When I double click a record I want to make a text box visible. When I double click on the empty space in the listview it also make the text box visible. Is there a way to stop this?

Cheers

ListView Selection
I have a problem with a ListView control. I'd like to disable the "rectangle seletion" - I have no ideea, how is the name of this feature, but I try to describe it. I mean the selecting of items with draging a rectangle from the empty area of the listview over some items. Has anyone an idea how to do this?

If I had an item selected and than deselect it (with ctrl and click) and make then a "rectangle selection" are all items selected under the rectangle, but the first item selected is selected too.

ListView Row Selection
I am creating a Report Manager and I was suggested to use a Listview and two options control to select print or view the report.
I did the code to display the rows report name now my problem is to select the row click on it and triger a sql query to print the selectioned report.

I do not know how to select the row because I never use ListView, here is my code

I will appreciate any help

Private Sub Form_Load()

' Initialize and fill up the ListView
With ListView1
Call MakeColumns


Call .ListItems.Add(, , "Today Orders")
Call .ListItems.Add(, , "Monthly Orders")
Call .ListItems.Add(, , "All Order Transactions")
Call .ListItems.Add(, , "Today Items Received")
Call .ListItems.Add(, , "Monthtly Items Received")
Call .ListItems.Add(, , "All Items Received")
Call .ListItems.Add(, , "Pay Stub")
Call .ListItems.Add(, , "Payroll Report")
Call .ListItems.Add(, , "Employee List")


End With

Show

End Sub
Private Sub MakeColumns()
' Clear the ColumnHeaders collection.
ListView1.ColumnHeaders.Clear
' Add one ColumnHeaders.
ListView1.ColumnHeaders.Add , , "Print Reports", 4000

End Sub

Selection On Listview
I use listview,I already uncheck the hide selection in the listview properties. How I can change the selection color to blue color?It color with gray color on the first record on my listview, so unable me to see the selected record.

Listview Selection
When a user clicks on a listview, how do I get the value of the fourth column in that row, which is a number?

Also, what else do I have to code for to check what the user has selected, is it KeyDown, KeyPress or KeyUp?

I am guessing KeyUp. Is that right?

Listview Selection
Hi,

is it possible and how to create a rts style mouse selection in a listview control?

Listview Selection
Hi it's me again...

Can u just guide me on this.

When my listview gets focus 1st item is always selected.
I dont want it that way...
When listview is loaded no item in it should be selected

Listview ... In Selection?
I have a few listview controls...

when I select an item.. sometime the word shortens and adds ...
is there a way around this?
I know when the words dont fit.. it adds the ... to indicate it continues...
but I dont want this to happen when I select an item

thanks!

Listview Selection
Hi,

I've got a listview.
The listview contains a numer of columns and a number of rows.
What I want to do is to be able to set the selecteditem to the row I've selected, regardless of the column I'm using.

For your information, it's for writing an ocx. That ocx can consist of multiple listviews. I want to be able to set the selecteditem whenever a user single-clicks on a row. When the user doubleclicks, the selecteditem should also be set properly after that the ocx goes into edit-mode for that particular listitem.

I've performed a search on this forum, but I haven't found a proper solution that solves my problem.

Any help is appreciated
Kind regards,
Mvrp350

Listview Selection Box
Hi I got a small problem with my listview but its annoying anyway. When I have some items selected and right click on the listview a popup menu pops up with options that can be executed. When I have clicked one of these options they will execute and after that the focus returns back to the ListView but the selection box doesnt dissapear. Without clicking in the ListView the selection box appears like it is still dragging to get a selection. I hope you understand what I mean, maybe the answer is simple but I havent figured it out. Thx

Listview - Row Selection
I am using a listview in my program with 30 rows

If i left lick on any row it gets selected, but if i right click on any row, then the row is not selected.

Ive added some code which runs when the user right clicks a row.

But now in my program the user first has to select the row he wants ie first he left clicks the row he wants and then right clicks on that row.

So is it possible to select the row whenever the user right clicks on any row in the listview.

ListView Selection
I need to be able to somehow tell if the user has made a selection (highlighted) an item in a ListView or if no selection has been made. I am new to the whole listview control and hoping this task can be accomplished without having to loop through the list.

Any ListView gurus out there?

ListView Selection
How do you programatically set the Selected row of a ListView so that it is highlighted?

I've tried:


Code:
Me.lstArticles.ListItems.Item(iOrderNbr).Selected = True


But that doesn't seem to work.

Thanks.
-Steve

Listview - Row Selection
Hi. I have a question regarding ListView. I want to be able to keep a selection of a row in a listview even though the focus is on other objects on the form. WIth normal lists, when a row is clicked, even though the list loses focus, you can still see that the row is selected.
Thank you.
TM

Stop Movement Of Listview Icon
hello friends,

I add items (as Icons) and set the view to Icons. When I select and move
one of the items within the listview control, it appears to drag outside the
boundaries of the listview control and the vscroll and hscroll bars appear.
The problem is I want the items to remain aligned, not randomly spread
around. Also, this is a problem because my list view control is about 2
inches square. Can I keep the icon within the white space of the control
and can I keep everything aligned?

How To Stop The Renew Index's For Listview ?
peace be with you

i make a small project used " listview "

i add a 3 items therefore the index's will be [ 1 - 2 - 3 ]

when i remove the index "2" the index's changes like this [ 1 - 2 ]

and number [2] is the index 3 before the removed

the question is :

how to set the index's not changes ??

thanks

Stop ListView Column Header
Hi Everyone,

I am using an example from VBnet about subclassing and responding to notifications from the ListView Header.

http://vbnet.mvps.org/index.html?cod...ifications.htm

The question I am trying to figure out is this. How can I get a column header to stop resizing once it has gotten to a location to a certain location. For example, stop column 1 from resizing any smaller when pt.X = 20. I would appreciate any help.

Thanks.

How To Stop First Colume Edit In A Listview
How do you stop first colume edit?

ListView - Stop Icons Moving
Hi,
I'm using a listview control in the Icon mode, to display a control panel for my application. The only problem is that when a user clicks an icon, when you move the mouse it moves the icon as well.

Is there any way to stop the user moving the icon?

Stop And Start A Service From A ListView
Hi

I want to be able to stop and start a service that is selected from a ListView, I've tried searching but cant find anything, does anyone have any ideas?

Thanks



LIVERPOOL FOOTBALL CLUB - 5 times Champions of Europe!! 1977, 1978, 1981, 1984, 2005

FA Cup Winners - 2006

Edited by - johneast on 3/15/2006 6:31:40 AM

Listview Bottom Selection
Hi There
how can i select last record by codes when i populate listview. it (listview) usually display first record after getting populated. I hv some 300 records and i need to select/show last record from bottom whenever i populate Lv. Please help

lstno = LvRough.ListItems.Count
LvRough.ListItems (SelectedItem.Index(LSTNO))

gives 'invalid use of property'

Thanks

ListView Selection Like ListBox
Has anyone any idea how to get a ListView in lvwList view to select in rows like ListBoxes instead of selecting only the text?

Thanks

ListView Selection Colour
Hi Guys,

Does anyone know of a way to change the selection highlight colour in the ListView control? I have the ".HideSelection" property to "False" and the current colour is a boring pale grey. Is there a way to change this colour?

Thanks in advance,
Addibo

Hidden Listview Selection
I have a listview (lvwContacts) box that retreives data from an Access 97 file.
I want the listview to display Name field, but when clicked, send MemberID to a text box next to it.(to retreive other info).

my Members table looks like this
MemberID Name Address PhoneNumber
0 Bob Smith 111 Test Rd. 555-5555
1 Jane Smith 101 Test Ln. 555-5555
2 Mary Smith 010 Test Rd. 555-5555

the form looks like this:

ListView Name: Bob Smith
0 Address: 111 Test Rd.
1 PhoneNumber: 555-5555
2

(0 is clicked in this case to info for MemberID 0 is displayed on the right)

Instead of the MemberID being in the list, I want to display the name,
I want to click the name and have the info show up on the right.

but when the ListView_Click() happens it checks for MemberID
(dont really want to change this yet as it would probably mean starting over..unless its really nessecary)
Here is the code for frmMain.frm
------------------------------------------------------------------
Option Explicit
Dim db As Database
Dim rs As Recordset
Dim lstmain1 As ListItem
Dim lstmain2 As ListItem
Dim clmhead1 As ColumnHeader
Dim clmhead2 As ColumnHeader

Private Sub Form_Load()
Set db = DBEngine.Workspaces(0).OpenDatabase(App.Path & "Members.mdb")
Set clmhead1 = lvwContacts.ColumnHeaders.Add(, , "MemberID", lvwContacts.Width)
Set clmhead2 = lvwContacts.ColumnHeaders.Add(, , "Name", lvwContacts.Width)
ContactView
End Sub

Private Sub lvwContacts_Click()
Set rs = db.OpenRecordset("Members")
While Not rs.EOF
If lvwContacts.SelectedItem.Text = rs!MemberID Then
txtName.Text = rs!Name
txtAddress.Text = rs!Address
txtPhone.Text = rs!PhoneNo
rs.MoveLast
rs.MoveNext
Else
rs.MoveNext
End If
Wend
End Sub


Public Sub ContactView()
Set rs = db.OpenRecordset("Members")
frmMain.lvwContacts.ListItems.Clear
While Not rs.EOF
Set lstmain1 = frmMain.lvwContacts.ListItems.Add(, , rs!MemberID)
rs.MoveNext
Wend
If rs.RecordCount = 0 Then
MsgBox "There are no records on the database"
Else
frmMain.lvwContacts.Enabled = True
frmMain.cmdCDelete.Enabled = True
frmMain.cmdCEdit.Enabled = True
End If
End Sub

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

I am VERY new to this stuff so I hope this isnt a stupid question.
I downloaded a source and am attempting to modify it to help me learn .

A thorough answer is greatly appreciated.

Thank you for your time.
MysticTymes

Listview Item Selection
If I click the 1st item in my listview how do I make it show its number like 1, and if I click the 2nd one it says 2.

ListView Selection Issue
I have a problem with a ListView that I am using from an Excel macro.

It appears that even when nothing is selected (i.e. on first drawing the control, item #1 is returned by theListView.Selected. My problem is that I have a delete button which deletes the selected item, and when nothing is selected, the first item gets deleted.

Now I have a work around by disabling the delete button until a click is registered, but I wondered if there was any other way. My original thought was that Selected would return -1, but I guess that does not happen...

Tel

Listview Selection Edit
Hello,

I have read much information on editing the listview selected items. however
for some reason I'm drawing a blank with regard to editing the data I need.

For example, I have a listview assoctied with the columns of my access database, and the data shows as intended. However, once it loads and I select a row and then send the selected data to textboxes.

Here is were i get confused after sending the data to the textbox how do i update the selected field in the db and listview box. I know I need to do some kind of refresh or update, i hoping someone could give me a code example.

Multiple Selection In A ListView
Good day everyone!

How to implement multiple selection in ListView? I want this so as to delete two or more selected row in a listview. thnks

Disable Listview Selection
How do disable Listview section, I just what to diplay items not select or have them highlighted.

Thanks

ListView Random Selection
I have a listview with some data in it, but my aim is to randomly select a line when i hit a button. So, i count the lines in the list view, then generate a random number between 1 and the amount of lines in the listview, but i dont know how i would go about selecting say line #5 ? If its even possible?

Listview Selection Color
hi,

We all knew that the current selection color of listview is blue during its focus and gray color when it is lost in focus. It is posible to change the color during lost focus. For ex. from gray to red.

Popskie,

Keeping Listview Selection Bar
Does anyone know how to retain the blue highlight bar in a listview control (set to report view) after it loses focus??
I know there is the option of it turning grey on lostfocus (HideSelection), or it disappearing totally, but I need to have a program displaying 2 listview controls, with the blue highlight bar (or even better a user defined colour!) on both lists, clearly showing a current "position" of both lists.

Is there an API call or something for this to change the default windows "lost focus" for the listview?

Any help appreciated....

Selection Row Printing In Listview
HI........
I HAVE TO PRINT SELECTED ROW IN A LISTVIEW CONTROL
TELL ME HOW CAN I DONE IT.
PLZ.

Selection Printing Using Listview ?
hi,
i have to print selected records viewed in a listview.
i dont know how ?
will u suggest me ?

ListView Selection Disappears?
Hey, all. I'm writing to you from my kitchen counter as I pack other items for a move halfway across the USA!

I'm using the ListView control in Report mode. Whenever I delete a row:


VB Code:
lstFruits.ListItems.Remove 2


...The selection disappears. Granted, that same index (two) is still selected, but the visual indicator of its selected status is now hidden. So, if someone uses the delete button again, they have no idea what they're about to delete.

Is this a bug in the control? Is there a workaround? I have HideSelection set to False, so that's not it. Hmm!

As usual, thanks for your help. Much appreciated.

Listview Invisible Selection
How do I turn off (hide) the selection bar on a listview. I am overlaying the listview with my own pretend selection (using the picture property and setting the listview background to transparent)

* I have tried turning off full row select, but then the first column gets selected.

* I have tried "Hideselection = True" but this only applies when the listview has lost its focus.

the only way I can think of is to set fullrowselect to false. Then create a first column which always has a width of 0, this means my selection would be hidden... but is there a better way?

Cheers

ListView Nodes Selection
Is there any way to cancel the selection of items within a ListView. For example, lets say you right click over a ListView and popup up a menu. After you have finished executing whatever the option you clicked in the mouse is in "selection" and if you move the mouse the items would be selected. How can I avoid that?

About Listview Automatically Selection
hi everybody,
i have one question about listview selection.
i have a listview. When i choose a record from the listview and press "Edit" button, a new form is being displayed. At the new form i can change the informations about this record and then when i press "Save" button, this screen is being closed and i can see the form with the listview control again. But i have to clear listview and i have to insert the records again to the listview after i save the record. Till this step everything is ok.
Now the top record in the listview is selected and i don't want this because there are lots of records at the listview and everytime i need to find and choose that record.
What i want to know is, the record that i choosed before should be selected at the listview but i don't know how to do.
is there anybody who knows how to do this?
i will be glad if you can help me on this issue.

thanks a lot.

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