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
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 :lol:
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.
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!
Re: Listview Gridlines VB.Net version?
any help on this please? haven't seen a work around so far...
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.
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...
Re: Listview Gridlines VB.Net version?
Set the .OwnerDraw property to True and draw your listview items yourself (including the grid lines).
Re: Listview Gridlines VB.Net version?
thanks! will try looking for the code specifically for the gridlines... =)