Click here to Skip to main content
15,902,445 members
Home / Discussions / C#
   

C#

 
GeneralRe: Problem with XML-Serializer Pin
Le centriste13-Jan-09 4:01
Le centriste13-Jan-09 4:01 
QuestionHow to use an image array in C# Pin
TJS4u13-Jan-09 1:44
TJS4u13-Jan-09 1:44 
AnswerRe: How to use an image array in C# Pin
DaveyM6913-Jan-09 2:02
professionalDaveyM6913-Jan-09 2:02 
QuestionOpen Document in Default Viewer Pin
half-life13-Jan-09 1:06
half-life13-Jan-09 1:06 
AnswerRe: Open Document in Default Viewer Pin
N a v a n e e t h13-Jan-09 1:20
N a v a n e e t h13-Jan-09 1:20 
GeneralRe: Open Document in Default Viewer Pin
half-life13-Jan-09 1:25
half-life13-Jan-09 1:25 
AnswerRe: Open Document in Default Viewer Pin
Giorgi Dalakishvili13-Jan-09 1:22
mentorGiorgi Dalakishvili13-Jan-09 1:22 
QuestionShutdown application? Pin
devvvy13-Jan-09 0:31
devvvy13-Jan-09 0:31 
AnswerRe: Shutdown application? Pin
Pete O'Hanlon13-Jan-09 0:39
mvePete O'Hanlon13-Jan-09 0:39 
GeneralRe: Shutdown application? Pin
devvvy13-Jan-09 0:41
devvvy13-Jan-09 0:41 
AnswerRe: Shutdown application? Pin
SeMartens13-Jan-09 0:48
SeMartens13-Jan-09 0:48 
Questionhow to disable multi select of checkbox in listview ? Pin
Denver Thomas13-Jan-09 0:10
Denver Thomas13-Jan-09 0:10 
AnswerRe: how to disable multi select of checkbox in listview ? Pin
Wendelius13-Jan-09 0:18
mentorWendelius13-Jan-09 0:18 
AnswerRe: how to disable multi select of checkbox in listview ? Pin
Reza Raad13-Jan-09 0:20
Reza Raad13-Jan-09 0:20 
AnswerRe: how to disable multi select of checkbox in listview ? PinPopular
hground26-Mar-10 6:30
hground26-Mar-10 6:30 
I know this question was asked over a year ago, but I have been searching for an answer myself with little success and wanted to get this out there to save others who may be searching the hours of frustration I encountered. I finally came up with the following VB .NET code to take care of the problem:
'Declare a Form global boolean to keep the ItemChecked event from being called in an infinite loop
Dim bFirstChange as Boolean = True

Private Sub Listview1_ItemChecked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ItemCheckedEventArgs) Handles Listview1.ItemChecked
    If ((ModifierKeys = Keys.Control) Or (ModifierKeys = Keys.Shift)) Then
        If (bFirstChange) Then
            bFirstChange = False
            e.Item.Checked = Not e.Item.Checked
        Else
            bFirstChange = True
        End If
        Exit Sub
    End If
    'Accentuate that the row is checked
    If (e.Item.Checked) Then
        e.Item.SubItems(0).Text = "+"
        e.Item.BackColor = Color.LightYellow
    Else
        e.Item.SubItems(0).Text = "-"
        e.Item.BackColor = Color.White
    End If
End Sub


This worked for me to keep the Checked property unchanged. Not sure about the "thread safe-ness" of this, but not a problem for me in the form I am working with. You should be able to easily convert this if you need it in C# instead of VB.
HTH - hground
GeneralRe: how to disable multi select of checkbox in listview ? Pin
molesworth26-Mar-10 7:27
molesworth26-Mar-10 7:27 
GeneralRe: how to disable multi select of checkbox in listview ? Pin
MarqW18-May-10 2:30
MarqW18-May-10 2:30 
GeneralRe: how to disable multi select of checkbox in listview ? [modified] Pin
mycleverscreenname23-Aug-10 8:04
mycleverscreenname23-Aug-10 8:04 
GeneralRe: how to disable multi select of checkbox in listview ? Pin
jerryno67-Oct-11 6:26
jerryno67-Oct-11 6:26 
GeneralRe: how to disable multi select of checkbox in listview ? Pin
MarqW9-Oct-11 20:44
MarqW9-Oct-11 20:44 
GeneralRe: how to disable multi select of checkbox in listview ? Pin
jerryno610-Oct-11 0:09
jerryno610-Oct-11 0:09 
SuggestionRe: how to disable multi select of checkbox in listview ? Pin
MarqW10-Oct-11 0:21
MarqW10-Oct-11 0:21 
Questionadd user control in datagridview in c# Pin
monuSaini13-Jan-09 0:08
monuSaini13-Jan-09 0:08 
AnswerRe: add user control in datagridview in c# Pin
Vivek Bhatnagar13-Jan-09 0:44
Vivek Bhatnagar13-Jan-09 0:44 
GeneralRe: add user control in datagridview in c# Pin
monuSaini13-Jan-09 0:51
monuSaini13-Jan-09 0:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.