NullText for C1Treeview Node

Posted by: kbj on 22 February 2023, 4:52 am EST

  • Posted 22 February 2023, 4:52 am EST

    Hi Folks,

    With an AllowEdit c1Treeview, is there a way to have a node by node Equivalent to C1TextBox’s NullText. The treeview nodes contain an object with a property named “title”; the treeview DisplayFieldName property is “title”. If the object’s title is nothing, I’d like the node display a default title comprised of some other property of the object.

    An example would be:

    If the object is a fiscal year that has an ending date property of December 31, 2023, if the user leaves the title property blank, the node would display “FYE December 31, 2023”. On entering edit mode, the editor should be blank. If the user exits the edit mode, and the value is still blank, the default value should be displayed.

    Any ideas?



  • Posted 22 February 2023, 6:32 pm EST


    You can override ToString() method and set a Default value to the title if it’s null or empty.

            Public Overrides Function ToString() As String
                If Title = "" Or Title = Nothing Then
                    Title = "Default Value"
                    Return Title
                End If
                Return MyBase.ToString()
            End Function

    Please refer the attached sample for the

    Best Regards,


  • Posted 23 February 2023, 1:07 am EST

    Hi Nitin,

    As you noticed, simply overriding the ToString Function, or as I did it:

        Public Property title As String
                If String.IsNullOrEmpty(_title) Then
                    Return "{Default Value}"
                    Return _title
                End If
            End Get
            Set(value As String)
                If Not Equals(value, _title) Then
                    _title = value
                End If
            End Set
        End Property

    doesn’t reset the displayed value to the default after editing and replacing the value to “”. You get around this by resetting the DataSource, which is awkward and you will notice collapses all the expanded branches after editing amongst other problems.

    The problem is that the node displayed value is now blank and not the ToString value or, in my case, the DisplayFieldName of the object.

    Reloading the node doesn’t work:

            Private editItem As ClassData
            Private Sub CellBeginEdit(sender As Object, e As C1TreeViewNodeCellCancelEventArgs)
                editItem = CType(e.Node.GetValue, ClassData)
            End Sub
            Private Sub CellEndEdit(sender As Object, e As C1TreeViewNodeCellEventArgs)
            End Sub

    I wish there was a way to “Refresh” the node after the edit.

  • Posted 26 February 2023, 4:50 pm EST


    We could see the issues you mentioned. As a workaround, you can use the way you mentioned i.e. returning the default value from the property if the value is empty or null.

    Then in the CellEndEdit’s event handler you can call the EndUpdate method of the TreeView. Please refer to the sample attached and let us know if you face any problems.


Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels