Search code examples
winformslistviewitemtreeviewitem

Limit TreeView/ListView item edit characters


I have a TreeView and a list view controls that both supports edit their item nodes, but I want to limit them to 256 characters max, one way to do it, is to validate the Length of the string in the OnAfterLabelEdit, but what I want to do it make the edit box stop accepting characters when it reaches 256. same as

TextBox.Maxlength


Solution

  • There is no easy way to do that with TreeView/ListView items unlike with TextBoxes. You could either try TVITEM structure or this. Or you could capture the text changed event and validate...