Exemple #1
0
        public override System.Collections.IEnumerable GetChildren(TreePath treePath)
        {
            List<DataRowNode> items = new List<DataRowNode>();

            if (treePath.IsEmpty() )
            {
                items.Add(m_root);
            }
            else
            {
                DataRowNode n = treePath.LastNode as DataRowNode;

                DataRow row = n.Row;
                int id = Convert.ToInt32(row[m_IDColumnName]);

                DataRow[] rows = m_table.Select("ParentID = " + id+" and "+m_IDColumnName+" <> "+id);
                foreach (DataRow r in rows)
                {
                    DataRowNode node = new DataRowNode(r,r["Name"].ToString());
                    node.Row = r;
                    //SampleApp.Properties.Resources.ResourceManager.
                    //node.Icon = new Bitmap(SampleApp.Properties.Resources.Records,new Size(15,15));
                    items.Add(node);
                }
            }
            return items;
        }
Exemple #2
0
        public override System.Collections.IEnumerable GetChildren(TreePath treePath)
        {
            List <DataRowNode> items = new List <DataRowNode>();

            if (treePath.IsEmpty())
            {
                items.Add(m_root);
            }
            else
            {
                DataRowNode n = treePath.LastNode as DataRowNode;

                DataRow row = n.Row;
                int     id  = Convert.ToInt32(row[m_IDColumnName]);

                DataRow[] rows = m_table.Select("ParentID = " + id + " and " + m_IDColumnName + " <> " + id);
                foreach (DataRow r in rows)
                {
                    DataRowNode node = new DataRowNode(r, r["Name"].ToString());
                    node.Row = r;
                    //SampleApp.Properties.Resources.ResourceManager.
                    //node.Icon = new Bitmap(SampleApp.Properties.Resources.Records,new Size(15,15));
                    items.Add(node);
                }
            }
            return(items);
        }
Exemple #3
0
        public override bool IsLeaf(TreePath treePath)
        {
            DataRowNode n = treePath.LastNode as DataRowNode;

            if (n.Row["IsFolder"] == DBNull.Value)
            {
                return(false);
            }
            return(!Convert.ToBoolean(n.Row["IsFolder"]));
        }
Exemple #4
0
 public DataTableTreeModel(DataTable table, string idColumnName)
 {
     m_table = table;
     m_IDColumnName = idColumnName;
     DataRow[] rows = table.Select(m_IDColumnName+" = ParentID");
     if( rows.Length ==0 )
     {
         throw new Exception("DataTableModel Requires a root Node");
     }
     m_root = new DataRowNode(rows[0],rows[0]["Name"].ToString());
     m_root.Row = rows[0];
 }
Exemple #5
0
 public DataTableTreeModel(DataTable table, string idColumnName)
 {
     m_table        = table;
     m_IDColumnName = idColumnName;
     DataRow[] rows = table.Select(m_IDColumnName + " = ParentID");
     if (rows.Length == 0)
     {
         throw new Exception("DataTableModel Requires a root Node");
     }
     m_root     = new DataRowNode(rows[0], rows[0]["Name"].ToString());
     m_root.Row = rows[0];
 }
Exemple #6
0
        //public event EventHandler<TreeModelEventArgs> NodesChanged;
        //public event EventHandler<TreeModelEventArgs> NodesInserted;
        //public event EventHandler<TreeModelEventArgs> NodesRemoved;
        //public event EventHandler<TreePathEventArgs> StructureChanged;
        public void AddChild(TreePath parent, string text)
        {
            DataRowNode n = parent.LastNode as DataRowNode;

               DataRow r =   m_table.NewRow();
               r["ID"] = GetNextID();
               r["ParentID"] = n.Row["ID"];
               r["IsFolder"] = false;
               r["Name"] = text;
               r["Tag"] = "";
               m_table.Rows.Add(r);
               DataRowNode child = new DataRowNode(r, text);
               OnStructureChanged(new TreePathEventArgs(parent));
        }
Exemple #7
0
        //public event EventHandler<TreeModelEventArgs> NodesChanged;

        //public event EventHandler<TreeModelEventArgs> NodesInserted;

        //public event EventHandler<TreeModelEventArgs> NodesRemoved;

        //public event EventHandler<TreePathEventArgs> StructureChanged;


        public void AddChild(TreePath parent, string text)
        {
            DataRowNode n = parent.LastNode as DataRowNode;

            DataRow r = m_table.NewRow();

            r["ID"]       = GetNextID();
            r["ParentID"] = n.Row["ID"];
            r["IsFolder"] = false;
            r["Name"]     = text;
            r["Tag"]      = "";
            m_table.Rows.Add(r);
            DataRowNode child = new DataRowNode(r, text);

            OnStructureChanged(new TreePathEventArgs(parent));
        }
        private void addNode_Click(object sender,
                                   EventArgs e)
        {
            if (treeViewAdv1.SelectedNode != null)
            {
                DataRowNode n = treeViewAdv1.SelectedNode.Tag as DataRowNode;
                if (!Convert.ToBoolean(n.Row["IsFolder"]))
                {
                    return;
                }

                TreePath parent = treeViewAdv1.GetPath(treeViewAdv1.SelectedNode);

                m_dataTableModel.AddChild(parent, "Hi " + DateTime.Today.ToShortDateString());
            }
        }