The following canChange event handler makes sure that the tree item’s text label does not have any spaces in it:

function TREEVIEW1_canChange

   if not empty( this.selected ) // Make sure there is a currently selected item 

      if " " $ this.selected.text 

         msgbox( "Spaces are not allowed", "Alert", 48 ) 

         return false 

      endif 

   endif 

return true 

Note that you would probably also use the onEditLabel event to warn the user of an invalid text label at the time they change it.