Results 1 to 8 of 8

Thread: Listview Gridlines VB.Net version?

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2009
    Posts
    43

    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

  2. #2
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,654

    Re: Listview Gridlines VB.Net version?

    vb Code:
    1. Imports System.Runtime.InteropServices
    2.  
    3. Public Class Form1
    4.     <DllImport("user32", CharSet:=CharSet.Auto, SetLastError:=True)> _
    5.     Private Shared Function SendMessage(ByVal hwnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
    6.     End Function
    7.  
    8.     Private Const LVM_FIRST As Integer = &H1000
    9.     Private Const LVM_SETEXTENDEDLISTVIEWSTYLE As Integer = (LVM_FIRST + 54)
    10.     Private Const LVS_EX_GRIDLINES As Integer = &H1
    11.  
    12.     Private Sub Form_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
    13.         Call SendMessage(ListView1.Handle, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_GRIDLINES, -1)
    14.     End Sub
    15. 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.

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2009
    Posts
    43

    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.

  4. #4

    Thread Starter
    Member
    Join Date
    Feb 2009
    Posts
    43

    Re: Listview Gridlines VB.Net version?

    any help on this please? haven't seen a work around so far...

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    Member
    Join Date
    Feb 2009
    Posts
    43

    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...

  7. #7

  8. #8

    Thread Starter
    Member
    Join Date
    Feb 2009
    Posts
    43

    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
  •  



Click Here to Expand Forum to Full Width