private void RemoveShortcutFromTree(TreeView targetTreeView, ShortcutOperations shortcutOperations) { if (targetTreeView.SelectedNode != null) { DataTreeNode node = (DataTreeNode)targetTreeView.SelectedNode; string nodeID = (node.Data as Shortcut).ID; shortcutOperations.DeleteNodeByID(nodeID); shortcutOperations.ReadXMLShortcuts(targetTreeView); } }
private void ReadXMLShortcuts() { DataSet ds = new DataSet(); string strFilename = "Shortcuts.xml"; ds.ReadXml(strFilename); ds.Tables[0].DefaultView.Sort = "OrderNo"; DataView dv = ds.Tables[0].DefaultView; trvShortcuts.Nodes.Clear(); foreach (DataRowView dvr in dv) { Shortcut s = new Shortcut(dvr["FilePath"].ToString().Trim(), dvr["Alias"].ToString().Trim()); s.ID = dvr["ID"].ToString(); s.OrderNo = dvr["OrderNo"].ToString(); DataTreeNode d = new DataTreeNode(s); trvShortcuts.Nodes.Add(d); } }
public void ReadXMLShortcuts(System.Windows.Forms.TreeView targetTreeView) { System.Data.DataSet ds = new System.Data.DataSet(); string strFilename = _shortcutsFile; ds.ReadXml(strFilename); if (ds.Tables.Count > 0) { ds.Tables[0].DefaultView.Sort = "OrderNo"; System.Data.DataView dv = ds.Tables[0].DefaultView; targetTreeView.Nodes.Clear(); foreach (System.Data.DataRowView dvr in dv) { Shortcut s = new Shortcut(dvr["FilePath"].ToString().Trim(), dvr["Alias"].ToString().Trim()); s.ID = dvr["ID"].ToString(); s.OrderNo = dvr["OrderNo"].ToString(); DataTreeNode d = new DataTreeNode(s); targetTreeView.Nodes.Add(d); } } }