Click here to Skip to main content
15,889,211 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: add user control in datagridview in c# Pin
Vivek Bhatnagar13-Jan-09 1:06
Vivek Bhatnagar13-Jan-09 1:06 
QuestionNeed Library for resume parsing [modified] Pin
Sudhir Mangla13-Jan-09 0:06
professionalSudhir Mangla13-Jan-09 0:06 
AnswerRe: Need Library for resume parsing Pin
lawrenceinba13-Jan-09 0:24
lawrenceinba13-Jan-09 0:24 
GeneralRe: Need Library for resume parsing Pin
Sudhir Mangla13-Jan-09 2:03
professionalSudhir Mangla13-Jan-09 2:03 
GeneralRe: Need Library for resume parsing Pin
lawrenceinba13-Jan-09 2:49
lawrenceinba13-Jan-09 2:49 
AnswerRe: Need Library for resume parsing Pin
Henry Minute13-Jan-09 6:08
Henry Minute13-Jan-09 6:08 
AnswerRe: Need Library for resume parsing Pin
Ben Fair13-Jan-09 6:29
Ben Fair13-Jan-09 6:29 

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.