|
-
Feb 15th, 2011, 12:50 PM
#1
Thread Starter
Member
Listview Gridlines VB.Net version?
anybody knows the vb.net version of the code below??? have tried the other solution using Class but I don't want to revise everything...
this listview gridlines issue hasn't been addressed in vb.net. nothing but faint lines are drawn as grid even when you the property as true... have searched around but couldn't find any... help please...
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal Msg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Const LVM_FIRST As Long = &H1000
Private Const LVM_SETEXTENDEDLISTVIEWSTYLE As Long = (LVM_FIRST + 54)
Private Const LVS_EX_GRIDLINES As Long = &H1
Private Sub Form_Load()
Call SendMessage(ListView1.hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_GRIDLINES, ByVal -1)
End Sub
-
Feb 15th, 2011, 05:02 PM
#2
Re: Listview Gridlines VB.Net version?
vb Code:
Imports System.Runtime.InteropServices Public Class Form1 <DllImport("user32", CharSet:=CharSet.Auto, SetLastError:=True)> _ Private Shared Function SendMessage(ByVal hwnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer End Function Private Const LVM_FIRST As Integer = &H1000 Private Const LVM_SETEXTENDEDLISTVIEWSTYLE As Integer = (LVM_FIRST + 54) Private Const LVS_EX_GRIDLINES As Integer = &H1 Private Sub Form_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load Call SendMessage(ListView1.Handle, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_GRIDLINES, -1) End Sub End Class
BUT 
The same thing is achieved simply by setting
Code:
ListView1.GridLines = True
I saw no difference. The alternative would be by setting the .OwnerDraw property to true and drawing the items yourself.
Last edited by cicatrix; Feb 15th, 2011 at 05:09 PM.
-
Feb 16th, 2011, 06:33 AM
#3
Thread Starter
Member
Re: Listview Gridlines VB.Net version?
thanks fior the quick reply... however, setting the gridlines = true shows only the faint lines... i am looking for better fix which would be visible for printing... preferably darker...
anyway, ill try the converted code... and will give further feedback... thanks!
Last edited by pidyok; Feb 16th, 2011 at 06:38 AM.
-
Mar 2nd, 2011, 06:04 PM
#4
Thread Starter
Member
Re: Listview Gridlines VB.Net version?
any help on this please? haven't seen a work around so far...
-
Mar 2nd, 2011, 06:15 PM
#5
Re: Listview Gridlines VB.Net version?
If you want to print the contents of a ListView then you would do so using a PrintDocument, just as you would do for pretty much all .NET printing. In that case, what gets printed is completely up to you at the time of printing. If you want grid lines then you can draw grid lines, regardless of whether they are displayed on screen or not.
-
Mar 3rd, 2011, 01:10 AM
#6
Thread Starter
Member
Re: Listview Gridlines VB.Net version?
yup, that's what I've done... unfortunately, i want to have listview gridlines to be darker... i have tried placing labels with height set to 1 just to get by but at some point, but the lines shift several pixels higher or lower after drawing of the form...
hope someone could point me the way how to change the color of the gridlines or at least darker... have tried the workaround offered in one of the threads here but it only draws the horizontal lines of the grid... and you have to populate empty sub items just to completely show the grid... doesn't apply for my app though...
-
Mar 3rd, 2011, 01:44 AM
#7
Re: Listview Gridlines VB.Net version?
Set the .OwnerDraw property to True and draw your listview items yourself (including the grid lines).
-
Mar 3rd, 2011, 02:34 AM
#8
Thread Starter
Member
Re: Listview Gridlines VB.Net version?
thanks! will try looking for the code specifically for the gridlines... =)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|