473,406 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Possible to disable a Row in ListView?

Can I make a row in a list view NONE selectable or disabled or something?

/Lars
Nov 20 '05 #1
4 8058
Handle the LVN_ITEMCHANGING and return true to prevent the selection
This should give you some help:
http://groups.google.se/groups?selm=...280a%40phx.gbl

/claes

"Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
news:#k**************@TK2MSFTNGP11.phx.gbl...
Can I make a row in a list view NONE selectable or disabled or something?

/Lars

Nov 20 '05 #2
okey, seems a bit tricky to me... I'm a VB junkie and C# for me is strange:)

/Lars

"Claes Bergefall" <cl*************@online.nospam> skrev i meddelandet
news:uM**************@TK2MSFTNGP12.phx.gbl...
Handle the LVN_ITEMCHANGING and return true to prevent the selection
This should give you some help:
http://groups.google.se/groups?selm=...280a%40phx.gbl
/claes

"Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
news:#k**************@TK2MSFTNGP11.phx.gbl...
Can I make a row in a list view NONE selectable or disabled or something?
/Lars


Nov 20 '05 #3
Try this:

Imports System.Runtime.InteropServices
Public Class ListViewEx
Inherits ListView
Public Const WM_USER As Integer = &H400
Public Const WM_NOTIFY As Integer = &H4E
Public Const OCM__BASE As Integer = WM_USER + &H1C00
Public Const OCM_NOTIFY As Integer = OCM__BASE + WM_NOTIFY
Public Const LVN_FIRST As Integer = 0 - 100
Public Const LVN_ITEMCHANGING As Integer = LVN_FIRST - 0
Public Const LVIF_STATE As Integer = &H8
Public Const LVIS_SELECTED As Integer = &H2
<StructLayout(LayoutKind.Sequential)> Public Structure NMHDR
Public hwndFrom As IntPtr
Public idFrom As Integer
Public code As Integer
End Structure
<StructLayout(LayoutKind.Sequential)> Public Structure POINT
Public x As Integer
Public y As Integer
End Structure
<StructLayout(LayoutKind.Sequential)> Public Structure NMLISTVIEW
Public hdr As NMHDR
Public iItem As Integer
Public iSubItem As Integer
Public uNewState As Integer
Public uOldState As Integer
Public uChanged As Integer
Public ptAction As POINT
Public lParam As Integer
End Structure
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = OCM_NOTIFY Then
Dim nm As NMHDR = CType(m.GetLParam(GetType(NMHDR)), NMHDR)
If nm.code = LVN_ITEMCHANGING Then
Dim nmlv As NMLISTVIEW =
CType(m.GetLParam(GetType(NMLISTVIEW)), NMLISTVIEW)
If nmlv.uChanged And LVIF_STATE Then
If nmlv.iItem = 0 Then
If nmlv.uNewState And LVIS_SELECTED Then
m.Result = New IntPtr(1)
Exit Sub
End If
End If
End If
End If
End If
MyBase.WndProc(m)
End Sub
End Class
/claes

"Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
news:#v*************@TK2MSFTNGP10.phx.gbl...
okey, seems a bit tricky to me... I'm a VB junkie and C# for me is strange:)
/Lars

"Claes Bergefall" <cl*************@online.nospam> skrev i meddelandet
news:uM**************@TK2MSFTNGP12.phx.gbl...
Handle the LVN_ITEMCHANGING and return true to prevent the selection
This should give you some help:

http://groups.google.se/groups?selm=...280a%40phx.gbl

/claes

"Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
news:#k**************@TK2MSFTNGP11.phx.gbl...
Can I make a row in a list view NONE selectable or disabled or something?
/Lars



Nov 20 '05 #4
Hi Lars,

Maybe this is a crazy answer, however why you want this, when you catch the
select in your program and than direct deselect that line, that is something
that a user in my opinion does not even see.

Cor
Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ASP .NET Newbie | last post by:
How can I disable ColumnClickEventHandler in ListView?
1
by: JC | last post by:
I am a newbe to C#, and I am required to enable and disable rows in a listview, depending on certain criteria. e.g. The listview contains - Apples Oranges Grapes I am required to have...
2
by: WAkthar | last post by:
Hi, Can anyone tell me how to disable the horizontal scrollbar and make it invisible in a listview? Thanks in advance!!
1
by: Li Pang | last post by:
Hi, I use checkbox in the listview, sometime, I want to disable these checkboxes, any body knows how to do so? Thanks advance
0
by: Li Pang | last post by:
Hi, I want to know how to disable some of checkbox in a listview programatically. thanks
6
by: Brandon McCombs | last post by:
Hello, I have a form that contains a listview on the left side and a column of buttons on the right side. Only some of the buttons do I want enabled all the time. The other buttons should be...
3
by: RT | last post by:
Is there any way to make Listview items invisible or otherwise keep them from displaying? Seems like temporarily removing, then restoring later would be a severe runtime hit.
1
by: Carl Johansson | last post by:
I have a virtual ListView (VirtualMode set to true). To make it more convenient for the users of the ListView to select its items, I've set the ListView's CheckBoxes property to true. However, in...
1
by: Bob | last post by:
Is there any practical way to disable items within a ListView control? I'd like to be able to 'filter' the list incrementally without actually removing anything (so I can remove the filter to get...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.