NX二次开发中treelist 树控件创建的逻辑过程
void tree::dialogShown_cb(){
try
{
//---- Enter your callback code here -----
tree_control0->InsertColumn(0,"Name",140);
tree_control0->InsertColumn(1,"Feature Type",90);
tree_control0->InsertColumn(2," Up to Date",70);
tree_control0->SetColumnResizePolicy(0,Tree::ColumnResizePolicyConstantWidth);
tree_control0->SetColumnResizePolicy(1,Tree::ColumnResizePolicyConstantWidth);
tree_control0->SetColumnResizePolicy(2,Tree::ColumnResizePolicyConstantWidth);
tree_control0->SetColumnDisplayType(2,Tree::ColumnDisplayIcon);
// create historymode
historyModeNode = createInsertParentNode(this->tree_control0,"History Mode" ,NULL,nodeIcons,nodeIcons,Tree::NodeInsertOptionAlwaysFirst);
viewNode = createInsertParentNode(this->tree_control0,"Model Views" ,historyModeNode,nodeIcons,nodeIcons,Tree::NodeInsertOptionLast);
camerasNode = createInsertParentNode(this->tree_control0,"Cameras" ,viewNode,nodeIcons,nodeIcons,Tree::NodeInsertOptionLast);
modelhistoryNode = createInsertParentNode(this->tree_control0,"Model History" ,camerasNode,nodeIcons,nodeIcons,Tree::NodeInsertOptionAlwaysLast);
tree_control0->SetSortRootNodes(false);
modelhistoryNode->Expand(Node::ExpandOptionExpand);
// get all the features with values
std::vector <Features::Feature *> nodeFeatures = getfeatures();
// insert the features
for(int i = 0 ; i < nodeFeatures.size();++i)
{
Node *featureNode = tree_control0->CreateNode(nodeFeatures->GetFeatureName());
tree_control0->InsertNode(featureNode,modelhistoryNode,NULL,Tree::NodeInsertOptionLast);
featureNode->SetColumnDisplayText(1, nodeFeatures->FeatureType());
featureNode->SetColumnDisplayText(2,"check");
}
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
tree::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
}
treelist的创建,需要在dialogShown_cb()里面定义treelist的内容
首先通过InsertColumn 定义列,有了列才能创建节点Node
这个顺序非常重要!
页:
[1]