2.1.26.68 tree_set_or_remove_attribute


Description

Add or remove an attribute on a treenode.

Syntax

bool tree_set_or_remove_attribute( TreeNode & tr, LPCSTR lpcszAttribute = NULL, bool bAdd = false, LPCSTR lpcszAttribValue = NULL )

Parameters

tr
[input] tree node to set or remove attribute
lpcszAttribute
[input]attribute string
bAdd
[input] ture will add attribute
lpcszAttribValue
[input] adding attribute value

Return

TRUE if success, else false

Examples

EX1

int tree_set_or_remove_attribute_ex1()
{
    Tree tr;
    TreeNode trNode = tr.AddNode("Root");
    trNode.SetAttribute(STR_LABEL_ATTRIB, "OK");
    
    string str;
    tree_set_or_remove_attribute(trNode, STR_LABEL_ATTRIB); //remove attribute    
    
    if( !trNode.GetAttribute(STR_LABEL_ATTRIB, str))    
        tree_set_or_remove_attribute(trNode, STR_LABEL_ATTRIB, true, "NewStr"); //add attribute
    
    return 1;
}

Remark

See Also

tree_remove_attribute

Header to Include

origin.h

Reference