Listview ghosted property

J

John

I have a VB6 project that uses the ghosted property of a
listitem in a listview.
I am trying to convert it to VB.NET but the ghosted
property appears to have been removed.
Is there a VB.NET equivalent?

Thanks
 
H

Herfried K. Wagner [MVP]

* "John said:
I have a VB6 project that uses the ghosted property of a
listitem in a listview.
I am trying to convert it to VB.NET but the ghosted
property appears to have been removed.
Is there a VB.NET equivalent?

No. The property doesn't exist and you cannot access it direclty. You
will have to dig down to the original 'LVITEM' structure (writing a new
wrapper for the Win32 ListView control).
 
J

John

This reply is for Peter Huang of microsoft.
I cannot find your reply to my original post.
I have followed the link in your email but the newsgroup
only shows my original post and a reply from someone
called Herfried.
I would very much like to see your reply - have you any
ideas as to why I can't?
 
P

Peter Huang

Hi John,

I agree with Herfried's idea.
Here I write the code for you, you may have a try to see if this is what
you want.

Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential)> _
Public Structure LVITEM
Public mask As Int32
Public iItem As Int32
Public iSubItem As Int32
Public state As Int32
Public stateMask As Int32
Public pszText As String
Public cchTextMax As Int32
Public iImage As Int32
Public lParam As IntPtr
End Structure

Public Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As IntPtr, ByVal wMsg As Int32, ByVal wParam As Integer, ByRef
lParam As LVITEM) As Integer
Public Const LVM_SETITEM = &H1006
Public Const LVIS_CUT = &H4
Public Const LVIF_STATE = &H8

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
ListView1.View = View.Details
' Add a column with width 80 and left alignment
ListView1.Columns.Add("File type", 80, HorizontalAlignment.Left)
ListView1.LargeImageList = ImageList1
ListView1.SmallImageList = ImageList1
ListView1.Items.Add("Item1", 0)
ListView1.Items.Add("Item2", 0)
Dim lv As New LVITEM
lv.iItem = 0
lv.mask = LVIF_STATE
lv.stateMask = LVIS_CUT
lv.state = LVIS_CUT
Dim rt As Boolean
rt = SendMessage(ListView1.Handle, LVM_SETITEM, 0, lv)
End Sub

LVITEM Structure
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/pla
tform/commctls/listview/structures/lvitem.asp

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
H

Herfried K. Wagner [MVP]

* "John said:
Thanks for the code Peter.
It works fine which makes me wonder why couldn't the
ghosted property have been left in if the underlying
mechanism is still available?

..NET Windows forms controls are mostly a wrapper for the underlying
Windows controls. For some reason, not all properties/... are exposed
to the user by the wrapper...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top