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
Solved

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

Posted on 1997-07-31
2
282 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

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…
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

856 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