Solved

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

Posted on 1997-07-31
2
285 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

740 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