返回从Windows表单类到另一个类的列表值

时间:2017-01-12 23:03:28

标签: c#

我确定这很简单,但遗憾的是,我也是。这是我的班级:

private List<string> colDescNode = new List<string>();

public List<string> ColDescNode
{
    get { return colDescNode; }
    set { colDescNode = value; } 
}

public TreeViewColorDescNodes()
{
    List<string> colDescNode = new List<string>();
    connect.Open();

    using (SqlCommand cmd = new SqlCommand("RMM3DMTagColors", connect))
    {
        cmd.CommandType = CommandType.StoredProcedure;
        using (SqlDataReader drReader = cmd.ExecuteReader())
        {
            while (drReader.Read())
            {
                if (!drReader.IsDBNull(0))
                    colDescNode.Add(drReader.GetString(0));
            }
        }
    }
}

}

到目前为止,这是我的表格。我已经查看了其他问题,但无法找到我理解的答案。在这一点上,一切都远远超出了我的技能水平。

public void fillTreeViewByList()
{
    connect.Open();

    TreeViewColorDescNodes firstNode = new TreeViewColorDescNodes();  // Everything from here down is probably wrong...

    tvDiscountMaintenance.Nodes.Add("Select All"); 
    foreach (var item in ColDescNode)
    {
        TreeNode colorDesc = new TreeNode(ColDescNode.ToString());
        tvDiscountMaintenance.Nodes[0].Nodes.Add(item.ToString());  
    }
}

我试图填写Treeview,但这是一组完全不同的问题。任何帮助是极大的赞赏。谢谢。

1 个答案:

答案 0 :(得分:0)

请尝试以下操作。我使用记事本编辑代码,所以请原谅任何语法错误

Traceback (most recent call last):
  File "C:\Python35\lib\site-packages\tensorflow\python\framework\tensor_shape.py", line 451, in __init__
    dims_iter = iter(dims)
  File "C:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 510, in __iter__
    raise TypeError("'Tensor' object is not iterable.")
TypeError: 'Tensor' object is not iterable.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/v-zhaom/OneDrive/testconv/test_placeholder.py", line 5, in <module>
    input = tf.placeholder(tf.int32, tf.pack([batchSize, 5]))
  File "C:\Python35\lib\site-packages\tensorflow\python\ops\array_ops.py", line 1579, in placeholder
    shape = tensor_shape.as_shape(shape)
  File "C:\Python35\lib\site-packages\tensorflow\python\framework\tensor_shape.py", line 821, in as_shape
    return TensorShape(shape)
  File "C:\Python35\lib\site-packages\tensorflow\python\framework\tensor_shape.py", line 454, in __init__
    self._dims = [as_dimension(dims)]
  File "C:\Python35\lib\site-packages\tensorflow\python\framework\tensor_shape.py", line 378, in as_dimension
    return Dimension(value)
  File "C:\Python35\lib\site-packages\tensorflow\python\framework\tensor_shape.py", line 33, in __init__
    self._value = int(value)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'Tensor'