Solved

ListView

Posted on 1998-10-19
7
640 Views
Last Modified: 2013-12-25
I want to select(show focus) all the subitems when I select particular list item in a list view with lvwReport View.I want show just like selecting a row when user clicks any item in a listview.

Any help or sample code??

Thanx
0
Comment
Question by:anilkumarv
  • 4
  • 3
7 Comments
 
LVL 15

Accepted Solution

by:
ameba earned 20 total points
ID: 1487825
VB6 has ListView control with property FullRowSelect.
In VB5, add this declarations to your module:
Public Const LVM_FIRST = &H1000
Public Const LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 54
Public Const LVM_GETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 55
Public Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" _
       (ByVal hwnd As Long, ByVal msg As Long, _
       ByVal wParam As Long, ByVal lParam As Long) As Long
Public Const LVS_FULLROWSELECT = &H20
Public Const LVS_EX_ONECLICKACTIVATE = &H40
Public Const LVS_EX_TWOCLICKACTIVATE = &H80

In your form, add this code in Form_Load event:
    With ListView1
        ' get the current ListView style
        rStyle = SendMessageLong(.hwnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0&, 0&)
        rStyle = rStyle Or LVS_EX_ONECLICKACTIVATE Or LVS_FULLROWSELECT
        ' set the new ListView style
        r = SendMessageLong(.hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0&, rStyle)
    End With

0
 

Author Comment

by:anilkumarv
ID: 1487826
Thanx ameba,

Your code has solved my problem.

I have one more query, posting as a question
0
 

Author Comment

by:anilkumarv
ID: 1487827
I want some documentation about the different parameters like LVM_SETEXTENDEDLISTVIEWSTYLE in the case of listview, to be passed to API's ??

How to get expertize in customizing the controls??

Any Suggestion???
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:anilkumarv
ID: 1487828
I want some documentation about the different parameters like LVM_SETEXTENDEDLISTVIEWSTYLE in the case of listview, to be passed to API's ??

How to get expertize in customizing the controls??

Any Suggestion???
0
 
LVL 15

Expert Comment

by:ameba
ID: 1487829
Don't customize too much. Try using regular VB properties. One day you will have to upgrade, and then you will have to delete a lot of code. In VB6 you will have more properties for listview, like Picture (for background), HotTracking, GridLines, CheckBoxes ...
Some constants you can try, use OR for combinations as in answer
       Public Const LVS_EX_GRIDLINES = &H1
       Public Const LVS_EX_CHECKBOXES = &H4
       Public Const LVS_EX_HEADERDRAGDROP = &H10
       Public Const LVS_EX_TRACKSELECT = &H8

0
 

Author Comment

by:anilkumarv
ID: 1487830
Thanx ameba,

Your code has solved my problem.

I have one more query, posting as a question
0
 
LVL 15

Expert Comment

by:ameba
ID: 1487831
Answer to your question on multiselect is correct.
For ListView not possible.
For FlexGrid, perhaps you can cheat :)
Property SelectionMode must be 0. When user selects an area, set background of selected cells to HIGHLIGHT (blue) color, save selection to a structure.
Type TP_SEL
 startcol as integer
 endcol as integer
 startrow as integer
 endrow as integer
End Type
Dim selections() as TP_SEL
Dim numselections as integer

When user clicks again holding CTRL, redimension your array to hold one selection more.
If not holding CTRL, start again: Redim selections(1)
Too complicated, isn't it?
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now