Listview BeginEdit and mouseclicks


G

Guest

This is driving me crazy. I have a listview that has LabelEdit set to true.
In the AfterLabelEdit event, I do my validation on the label text. If the
label isn't valid, it sets e.canceledit = true and calls the BeginEdit event.
I have included below the entire event handler code again as shown at the
end of this post.

Assume for this scenario that the label edited to an invalid value

After editing the value, if the user tabs away from the label, the code
executes as expected showing the messagebox and retruning to the label in
edit mode.

If the user edits the label and clicks away from the label, the validation
executes and presents the messagebox but after dismissing the messagebox, the
label will not automatically go back into edit mode (although it does have a
focus rectangle).

I have walked through the code and the sequence of events are the same
reguardless of how the users moves away from the label being edited. The
mouse click away from the label seems to be the culprit but for the life of
me I can't find a way around it.

Anyone have any insight into this?

Thanks

Private Sub ListView1_AfterLabelEdit(ByVal sender As Object, _
ByVal e As System.Windows.Forms.LabelEditEventArgs) _
Handles ListView1.AfterLabelEdit

Dim oIssueResponse As clsIssueResponse
Dim sName As String
Dim sPrompt As String

Dim i16ID As Int16

'Is the lable edited?
If e.Label Is Nothing Then
'There is No edit on the label,
Exit Sub
Else
'There Is edit on the label,
' take the label
sName = e.Label
End If

i16ID = CType(ListView1.FocusedItem.Tag, Int16)

'Validation
For Each oIssueResponse In mcolIssueResponses
If oIssueResponse.Name = sName And oIssueResponse.ID <> i16ID Then

sPrompt = "Cannot rename Issue Response: " & _
"An Issue Response with the name you specified already
exists. " & _
"Please specify a new name."

MsgBox(sPrompt, MsgBoxStyle.Exclamation, _
"Error renaming Issue Response")

e.CancelEdit() = True
ListView1.FocusedItem.BeginEdit()

Exit Sub

End If

Next oIssueResponse

Call UpdateIssueResponse(i16ID, sName)

End Sub
 
Ad

Advertisements


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

Similar Threads

Mouseclick 3
Simulate mouseclicks 1
mouseclick on a toostripstatuslabel 2
BeginEdit Method (Event?) 13
BeginEdit/EndEdit does not work 4
simulate a mouseclick on a highlighted node? 3
listview 1
listview? 1

Top