How to mix databound and static levels in a TreeView?

后端 未结 4 1563
感动是毒
感动是毒 2021-02-03 10:23

I have a collection of Database objects, each containing collections of Schema objects and User objects. I want to bind them to a TreeView, but adding

4条回答
  •  不思量自难忘°
    2021-02-03 10:44

    Here's a modification of Josh's solution to work with SMO (my original problem statement):

    
        
            
        
        
            
                
                    
                        
                    
                    
                    
                
            
            
        
        
            
        
        
            
        
    
    

    and the modified converter:

    public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        FolderNode[] result = new FolderNode[values.Length];
        for (int i = 0; i < values.Length; ++i)
        {
            result[i].Items = (IEnumerable)values[i];
            result[i].Name = values[i] is UserCollection ? "Users" : "Schemas";
        }
        return result;
    }
    

    Attribution Note: Content copied from OP's final solution, posted as an edit to the question, rather than as an answer

提交回复
热议问题