Disable label edit in a MouseClick action
In WinForms controls, how can I disable label edit when I click in an item of controls like ListView, TreeView, etc?, without disabling the editing capability (LabelEdit
property)?
I want to do that because the following behaviour is anoying and problematic: "Select an item of one of those control, change the focus to other application, click back in the item" and then 开发者_运维知识库the label edit start automatically. Perhaps I want to only recover the focus and the selection.
Something similar happens when you change focus between controls of the same app, but in this situation I stop this behaviour cleaning the items selection at the moment of entering the control.
For the first described problem that is useless.
you can do that by handling BeforeLabelEdit of tree
private void treeView1_BeforeLabelEdit(object sender, NodeLabelEditEventArgs e)
{
//if you want to edit in some special case write your condition here
e.CancelEdit = true;
}
精彩评论