Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select All in List 1

Status
Not open for further replies.

M444

Programmer
Feb 24, 2004
76
US
Hi,

Using MS Spy++ I see that a listbox in a program has an Extended Style called LVS_EX_FULLROWSELECT can this be used to select the whole list? the same way WM_LBUTTONDOWN can be used to push the button down?
 
A listbox doesn't. I assume that you actually mean a ListView? If you do the style actually means that, if the ListView is displaying in Report style, the whole row is highlighted if an item is clicked.

Both the lvwReport view style and FullRowSelect can be selected for the ListView in VB's IDE.
 
Thank you Strongm,

Yes you are right it is a listview... I found what looks to be a way to select all the items in the listview. Everytime I run it, however, the program which contains the listview gives me an exception error... Any ideas?

The following code can be found in whole at:
Public Sub SelectAllListItems(lvX As ListView)
On Error Resume Next
Dim LV As LV_ITEM
Dim numSelected As Long
Dim iX As Integer

With LV
.mask = LVIF_STATE
.State = &HF
.stateMask = LVIS_SELECTED
End With

Call SendMessage(lvX.hwnd, LVM_SETITEMSTATE, -1, LV)
End Sub
 
You really don't need to go to the API for this...assuming that the MultiSelect property is set to True for the listview the following code (or a variant) should do the trick:
Code:
[COLOR=blue]
    Dim myitem As ListItem
    
    For Each myitem In ListView1.ListItems
        myitem.Selected = True
    Next
[/color]


 
strongm,

I appologize for not being clear, but the listview control is located in software from an outside party.

I dont understand how I could select all of the items with the above code, unless the listview control was part of my own program. Am I missing something?

Thank You Again,

 
Ah - right. No, sorry. Didn't properly appreciate that you were trying access a different program
 
Does anyone know of a way to select all of the items in a listview which is located on a thrid party program?


or how I could set lvX as the EXISTING listview with the hwnd or another method?

in other words Set lvX = Existing listview

Public Sub SelectAllListItems(lvX As ListView)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top