P/Invoke and ListView

  • Thread starter Thread starter Zahid
  • Start date Start date
Z

Zahid

Hi,

Ive got a piece of code that sets gridlines to a listview.
However I only want the horizontal lines appearing and
not the vertical. Does anyone know how to change the code
for this to happen?

Heres the code:

Public Class Helper
Public Sub New()

End Sub
Private Const LVM_GETEXTENDEDLISTVIEWSTYLE As Integer
= &H1037
Private Const LVM_SETEXTENDEDLISTVIEWSTYLE As Integer
= &H1036
Private Const LVS_EX_GRIDLINES As Integer = &H1

Private Declare Function SendMessage Lib "coredll.dll"
Alias "SendMessageW" (ByVal hWnd As Integer, ByVal wMsg
As Integer, ByVal wParam As Integer, ByVal lParam As
Integer) As Integer

Private Declare Function GetFocus Lib "coredll.dll" ()
As Integer

Public Shared Sub SetGridLines(ByVal lvw As
System.Windows.Forms.ListView)

lvw.Focus()
Dim hWnd As Integer = GetFocus()
Dim extendedStyle As Integer =
SendMessage(hWnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)

extendedStyle = extendedStyle Or LVS_EX_GRIDLINES
SendMessage(hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0,
extendedStyle)

Frm2.ListView1.Invalidate()
End Sub

End Class


Thanks in advance.
 
Hi,

I dont think there is any option for displaying only horizontal lines. if u
apply LVS_EX_GRIDLINES both lines will come.

Girish.
 
There are thousands of constants. The ListView uses probably a few dozen.
I think they're all in winuser.h.
 
Here's the help page with them on it...

Paul T.

-----

Microsoft Windows CE .NET 4.2

List View StylesSee Also
Control Styles | Window and Message Box Styles | List-View Controls
Reference

The following table shows the styles that are supported by Windows CE.

List view style Description
LVS_ALIGNLEFT Specifies that items are left-aligned in icon view and small
icon view.
LVS_ALIGNTOP Specifies that items are aligned with the top of the list view
control in icon view and small icon view.
LVS_AUTOARRANGE Specifies that icons automatically remain arranged in icon
view and small icon view.
LVS_EDITLABELS Enables item text to be edited in place. The parent window
must process the LVN_ENDLABELEDIT notification message.
LVS_EX_CHECKBOXES Enables items in a list view control to be displayed as
check boxes. This style uses item state images to produce the check box
effect.
LVS_EX_FULLROWSELECT Specifies that when an item is selected, the item and
all of its subitems are highlighted. This style is available only in
conjunction with the LVS_REPORT style.
LVS_EX_GRADIENT Not supported.
LVS_EX_GRIDLINES Displays gridlines around items and subitems. This style is
available only in conjunction with the LVS_REPORT style.
LVS_EX_HEADERDRAGDROP Enables drag-and-drop reordering of columns in a list
view control. This style is only available to list view controls that use
the LVS_REPORT style.
LVS_EX_SUBITEMIMAGES Enables images to be displayed for subitems. This style
is available only in conjunction with the LVS_REPORT style.
LVS_ICON Specifies icon view.
LVS_LIST Specifies list view.
LVS_NOCOLUMNHEADER Specifies that no column header is displayed in report
view, which is the default view.
LVS_NOLABELWRAP Displays item text on a single line in icon view. By
default, item text might wrap in icon view.
LVS_NOSCROLL Disables scrolling, so all items must be displayed within the
client area.
LVS_NOSORTHEADER Specifies that column headers do not work like buttons.
This style is useful if clicking a column header in report view does not
carry out any action, such as sorting.
LVS_OWNERDATA Creates a virtual list view control.
LVS_OWNERDRAWFIXED Enables the owner window to paint items in report view.
The list view control sends a WM_DRAWITEM message to paint each item; it
does not send separate messages for each subitem. The itemData member of the
DRAWITEMSTRUCT structure contains the item data for the specified list view
item.
LVS_REPORT Specifies report view.
LVS_SHAREIMAGELISTS Specifies that the control does not destroy the image
lists assigned to it when it is destroyed. This style enables the same image
lists to be used with multiple list view controls.
LVS_SHOWSELALWAYS Always shows the selection highlighted, even if the
control is not activated.
LVS_SINGLESEL Enables only one item to be selected at a time. By default,
multiple items can be selected.
LVS_SMALLICON Specifies small icon view.
LVS_SORTASCENDING Sorts items based on item text in ascending order.
LVS_SORTDESCENDING Sorts items based on item text in descending order.

See Also
Control Styles | Window and Message Box Styles | List-View Controls
Reference




----------------------------------------------------------------------------
 
The actual constant values for ListView can be found in commctrl.h in the
PPC 200X SDK
 
Back
Top