Which way I can forbid editing node labels in TreeView if I want some labels be able to be edited and others no?

StackOverflow https://stackoverflow.com/questions/22127366

質問

I set LabelEdit to true and all labels becomes editable. How I can forbid editing level 0 nodes?

役に立ちましたか?

解決

Assuming WinForms, try canceling the edit in the BeforeLabelEdit event:

public Form1() {
  InitializeComponent();
  treeView1.BeforeLabelEdit += treeView1_BeforeLabelEdit;
}

void treeView1_BeforeLabelEdit(object sender, NodeLabelEditEventArgs e) {
  if (e.Node.Level == 0) {
    e.CancelEdit = true;
  }
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top