Solved

(Grid)Lines in a ListView /Report mode control ?

Posted on 1997-07-31
2
278 Views
Last Modified: 2008-03-10
G'day again !

How to display rows & columns lines (separators) in a ListView in Report mode to make it looks like a grid, then I'll use this control, since it has many more useful events than the FlexGrid. (And a true PROPORTIONAL scroll bar thumb !)

I know it's possible to do it in a combo box, but I can't find back the infos, coz I figure out it's the same API call to perform this trick on a ListView control.

All my thanks in advance, dear Experts

Regards
0
Comment
Question by:Krosos
2 Comments
 
LVL 3

Accepted Solution

by:
ESI earned 100 total points
ID: 1429176
By setting a ListView extended style bit using the API SendMessage with the message LVS_EX_GRIDLINES, the ListView columns and rows will be separated by a gray grid line.

Place the following API declare code into the general declarations area of a bas module:

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

Const LVM_FIRST = &H1000
Const LVM_SETEXTENDEDLISTVIEWSTYLE = (LVM_FIRST + 54)
Const LVM_GETEXTENDEDLISTVIEWSTYLE = (LVM_FIRST + 55)

Const LVS_EX_FULLROWSELECT = &H20
Const LVS_EX_GRIDLINES = &H1

Then, once the list view populated, (or probably it works too on an empty listview), set the right bit :

    Dim rStyle As Long, r As Long
   
   'get the current ListView style  
    rStyle = SendMessageLong(ListView1.hWnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0&, 0&)

   'set the extended bit            
   rStyle = rStyle Or LVS_EX_GRIDLINES

   'or if u want remove the extended bit :
'   rStyle = rStyle Xor LVS_EX_GRIDLINES
   
   'set the new ListView style  
    r = SendMessageLong(ListView1.hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0&, rStyle)

And U probably like the enable the system to highlight the entire row of a ListView (Looks far better)
The solution then is the message LVS_FULLROWSELECT :

Public Const LVS_EX_FULLROWSELECT = &H20
and perform the same operations as below (in fact, you can set the both bits at the same time indeed)
Above replace the line by

      rStyle = rStyle Or LVS_EX_GRIDLINES Or LVS_EX_FULLROWSELECT

that's all !

Well, have fun with our new improved ListView reports !
Bye
0
 

Author Comment

by:Krosos
ID: 1429177
Wow, thanks a lot ! it works fine. I give you 110 pts (no more, sorry)

Regards,
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

743 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

8 Experts available now in Live!

Get 1:1 Help Now