1. using Endv.Tools;
  2. using System;
  3. using System.Data;
  4. using System.Drawing;
  5. using System.IO;
  6. using System.Windows.Forms;
  7.  
  8. namespace Endv
  9. {
  10.  
  11. public class Form1 : System.Windows.Forms.Form
  12. {
  13.  
  14. private string DBConStr = "";
  15. private string AppPath = "";
  16. private ContextMenu tvSample1Menu = new ContextMenu();
  17. private ContextMenu tvSample2Menu = new ContextMenu();
  18. private System.ComponentModel.IContainer components;
  19. private System.Windows.Forms.Label label1;
  20. private System.Windows.Forms.TreeView TreeView1;
  21. private System.Windows.Forms.Button button1;
  22. private System.Windows.Forms.Button button2;
  23. private System.Windows.Forms.TreeView TreeView2;
  24. private System.Windows.Forms.Label label2;
  25. private System.Windows.Forms.Button button3;
  26. private System.Windows.Forms.Button button4;
  27. private System.Windows.Forms.Button button5;
  28. private System.Windows.Forms.Button button6;
  29. private DataGridView dataGridView1;
  30. private System.Windows.Forms.ImageList imageList1;
  31.  
  32. #region Form Load
  33. private void Form1_Load(object sender, System.EventArgs e)
  34. {
  35.  
  36. UI.Hourglass(true);// 获取等待光标,通常是沙漏形状
  37.  
  38. try
  39. {
  40.  
  41. AppPath = UI.GetAppPath();
  42. DBConStr = SqlHelper.connectionString;
  43. //DBConStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + AppPath + "sample.mdb";
  44. //DBConStr = "Provider= Data Source=(local);Initial Catalog=oittest;User ID=sa;Password=123";
  45.  
  46. tvSample1Menu.MenuItems.Add("Insert",
  47. new EventHandler(tvSample1RightClickInsert));
  48.  
  49. tvSample1Menu.MenuItems.Add("Edit",
  50. new EventHandler(tvSample1RightClickEdit));
  51.  
  52. tvSample1Menu.MenuItems.Add("Nudge Up",
  53. new EventHandler(tvSample1RightClickNudgeUp));
  54.  
  55. tvSample1Menu.MenuItems.Add("Nudge Down",
  56. new EventHandler(tvSample1RightClickNudgeDown));
  57.  
  58. tvSample1Menu.MenuItems.Add("Delete",
  59. new EventHandler(tvSample1RightClickDelete));
  60.  
  61. tvSample2Menu.MenuItems.Add("Insert",
  62. new EventHandler(tvSample2RightClickInsert));
  63.  
  64. tvSample2Menu.MenuItems.Add("Edit",
  65. new EventHandler(tvSample2RightClickEdit));
  66.  
  67. tvSample2Menu.MenuItems.Add("Nudge Up",
  68. new EventHandler(tvSample2RightClickNudgeUp));
  69.  
  70. tvSample2Menu.MenuItems.Add("Nudge Down",
  71. new EventHandler(tvSample2RightClickNudgeDown));
  72.  
  73. tvSample2Menu.MenuItems.Add("Delete",
  74. new EventHandler(tvSample2RightClickDelete));
  75.  
  76. LoadAllTrees();
  77.  
  78. TreeView1.AllowDrop = true;
  79. TreeView2.AllowDrop = true;
  80.  
  81. }
  82. catch (Exception err) { UI.Hourglass(false); UI.ShowError(err.Message); }
  83. finally { UI.Hourglass(false); }
  84. }
  85. #endregion
  86.  
  87. #region Load All Trees
  88. private void LoadAllTrees()
  89. {
  90.  
  91. try
  92. {
  93. LoadTree(TreeView1, Datas.emp.GetHierarchy());
  94. LoadTree(TreeView2, Datas.emp.GetHierarchy( ));
  95. //Datas.emp.GetHierarchy(DBConStr, "A01")
  96. }
  97. catch (Exception) //
  98. { throw; }
  99. }
  100. #endregion
  101.  
  102. #region Load Tree
  103. private void LoadTree(TreeView tv, DataSet ds)
  104. {
  105.  
  106. UI.Hourglass(true);
  107.  
  108. try
  109. {
  110.  
  111. TreeViewUtil.LoadFromDataSet(tv, ds, "Description");//描述
  112.  
  113. if (tv.Nodes.Count > )
  114. {
  115. tv.Nodes[].Expand();
  116. }
  117.  
  118. }
  119. catch (Exception) { throw; }
  120. finally
  121. {
  122. UI.Hourglass(false);
  123. }
  124. }
  125. #endregion
  126.  
  127. #region TreeView1 右键删除 Right Click Delete
  128. private void tvSample1RightClickDelete(object sender, System.EventArgs e)
  129. {
  130.  
  131. UI.Hourglass(true);
  132.  
  133. try
  134. {
  135. TreeViewUtil.DeleteNode(TreeView1, true);
  136. }
  137. catch (Exception err) { UI.ShowError(err.Message); }
  138. finally { UI.Hourglass(false); }
  139. }
  140. #endregion
  141.  
  142. #region TreeView2 右键删除 Right Click Delete
  143. private void tvSample2RightClickDelete(object sender, System.EventArgs e)
  144. {
  145.  
  146. UI.Hourglass(true);
  147.  
  148. try
  149. {
  150. TreeViewUtil.DeleteNode(TreeView2, true);
  151. }
  152. catch (Exception err) { UI.ShowError(err.Message); }
  153. finally { UI.Hourglass(false); }
  154. }
  155. #endregion
  156.  
  157. #region tvSample1 Right Click Edit
  158. private void tvSample1RightClickEdit(object sender, System.EventArgs e)
  159. {
  160.  
  161. UI.Hourglass(true);
  162.  
  163. try
  164. {
  165.  
  166. TreeNode node = TreeView1.SelectedNode;
  167.  
  168. if (node == null) { return; }
  169.  
  170. node.TreeView.LabelEdit = true;
  171.  
  172. node.BeginEdit();
  173.  
  174. }
  175. catch (Exception err) { UI.ShowError(err.Message); }
  176. finally { UI.Hourglass(false); }
  177. }
  178. #endregion
  179.  
  180. #region tvSample2 Right Click Edit
  181. private void tvSample2RightClickEdit(object sender, System.EventArgs e)
  182. {
  183.  
  184. UI.Hourglass(true);
  185.  
  186. try
  187. {
  188.  
  189. TreeNode node = TreeView2.SelectedNode;
  190.  
  191. if (node == null) { return; }
  192.  
  193. node.TreeView.LabelEdit = true;
  194.  
  195. node.BeginEdit();
  196.  
  197. }
  198. catch (Exception err) { UI.ShowError(err.Message); }
  199. finally { UI.Hourglass(false); }
  200. }
  201. #endregion
  202.  
  203. #region tvSample1 Right Click Nudge Up
  204. private void tvSample1RightClickNudgeUp(object sender, System.EventArgs e)
  205. {
  206.  
  207. UI.Hourglass(true);
  208.  
  209. try
  210. {
  211. TreeViewUtil.NudgeUp(TreeView1.SelectedNode);
  212. }
  213. catch (Exception err) { UI.ShowError(err.Message); }
  214. finally { UI.Hourglass(false); }
  215. }
  216. #endregion
  217.  
  218. #region tvSample1 Right Click Nudge Down
  219. private void tvSample1RightClickNudgeDown(object sender, System.EventArgs e)
  220. {
  221.  
  222. UI.Hourglass(true);
  223.  
  224. try
  225. {
  226. TreeViewUtil.NudgeDown(TreeView1.SelectedNode);
  227. }
  228. catch (Exception err) { UI.ShowError(err.Message); }
  229. finally { UI.Hourglass(false); }
  230. }
  231. #endregion
  232.  
  233. #region tvSample2 Right Click Nudge Up
  234. private void tvSample2RightClickNudgeUp(object sender, System.EventArgs e)
  235. {
  236.  
  237. UI.Hourglass(true);
  238.  
  239. try
  240. {
  241. TreeViewUtil.NudgeUp(TreeView2.SelectedNode);
  242. }
  243. catch (Exception err) { UI.ShowError(err.Message); }
  244. finally { UI.Hourglass(false); }
  245. }
  246. #endregion
  247.  
  248. #region tvSample2 Right Click Nudge Down
  249. private void tvSample2RightClickNudgeDown(object sender, System.EventArgs e)
  250. {
  251.  
  252. UI.Hourglass(true);
  253.  
  254. try
  255. {
  256. TreeViewUtil.NudgeDown(TreeView2.SelectedNode);
  257. }
  258. catch (Exception err) { UI.ShowError(err.Message); }
  259. finally { UI.Hourglass(false); }
  260. }
  261. #endregion
  262.  
  263. #region tvSample1 Right Click Insert
  264. private void tvSample1RightClickInsert(object sender, System.EventArgs e)
  265. {
  266.  
  267. UI.Hourglass(true);
  268.  
  269. try
  270. {
  271.  
  272. TreeNode node = TreeView1.SelectedNode;
  273.  
  274. if (node == null) { return; }
  275.  
  276. InsertNewNode(node);
  277.  
  278. }
  279. catch (Exception err) { UI.ShowError(err.Message); }
  280. finally { UI.Hourglass(false); }
  281. }
  282. #endregion
  283.  
  284. #region tvSample2 Right Click Insert
  285. private void tvSample2RightClickInsert(object sender, System.EventArgs e)
  286. {
  287.  
  288. UI.Hourglass(true);
  289.  
  290. try
  291. {
  292.  
  293. TreeNode node = TreeView2.SelectedNode;
  294.  
  295. if (node == null) { return; }
  296.  
  297. InsertNewNode(node);
  298.  
  299. }
  300. catch (Exception err) { UI.ShowError(err.Message); }
  301. finally { UI.Hourglass(false); }
  302. }
  303. #endregion
  304.  
  305. #region Insert New Node
  306. private void InsertNewNode(TreeNode node)
  307. {
  308.  
  309. DataRow row = null;
  310. DataRow ParentRow = null;
  311. DataTable dt = null;
  312. int newindex = ;
  313.  
  314. try
  315. {
  316.  
  317. ParentRow = (DataRow)node.Tag;
  318.  
  319. if (ParentRow == null) { return; }
  320.  
  321. newindex = int.Parse(ParentRow["SortOrder"].ToString()) + ;
  322.  
  323. dt = ParentRow.Table;
  324.  
  325. row = dt.NewRow();
  326.  
  327. row["ObjectID"] = Guid.NewGuid().ToString();
  328. row["ObjectTypeID"] = ;
  329. row["ModelID"] = int.Parse(ParentRow["ModelID"].ToString());
  330. row["NodeID"] = Guid.NewGuid().ToString();
  331. row["ParentNodeID"] = ParentRow[dt.PrimaryKey[].ColumnName].ToString();
  332. row["Description"] = "New Node";
  333. row["ForeColor"] = "#000000";
  334. row["BackColor"] = "#FFFFFF";
  335. row["ImageIndex"] = ;
  336. row["SelectedImageIndex"] = ;
  337. row["Checked"] = true;
  338. row["ActiveID"] = ;
  339. row["NamedRange"] = "";
  340. row["NodeValue"] = "";
  341. row["LastUpdateTime"] = DateTime.Now;
  342. row["SortOrder"] = newindex;
  343.  
  344. dt.Rows.Add(row);
  345.  
  346. node.Nodes.Add(TreeViewUtil.GetTreeNodeFromDataRow(row, "Description"));
  347.  
  348. }
  349. catch (Exception)
  350. {
  351. throw;
  352. }
  353.  
  354. }
  355. #endregion
  356.  
  357. #region Edit Node
  358. private void EditNode(TreeNode node, string newText)
  359. {
  360. DataRow row = null;
  361.  
  362. try
  363. {
  364.  
  365. if (node == null) { return; }
  366.  
  367. row = (DataRow)node.Tag;
  368.  
  369. if (row == null) { return; }
  370.  
  371. row["Description"] = newText;
  372.  
  373. }
  374. catch (Exception) { throw; }
  375.  
  376. }
  377. #endregion
  378.  
  379. #region 重载测试数据 Button Reload Test Data
  380. private void button1_Click(object sender, System.EventArgs e)
  381. {
  382. LoadAllTrees();
  383. }
  384. #endregion
  385.  
  386. #region 导出树 Button Export Trees To Xml
  387. private void button2_Click(object sender, System.EventArgs e)
  388. {
  389.  
  390. string filename = "";
  391. DataSet ds;
  392. DataRow row;
  393. DataSet compareds;
  394.  
  395. try
  396. {
  397.  
  398. UI.Hourglass(true);
  399.  
  400. // Write out the contents of tvSample to disk
  401.  
  402. filename = Path.Combine(AppPath, "treeview1.xml");
  403.  
  404. if (File.Exists(filename)) { File.Delete(filename); }
  405.  
  406. if (TreeView1.Nodes.Count == ) { return; }
  407.  
  408. row = (DataRow)TreeView1.Nodes[].Tag;
  409.  
  410. ds = row.Table.DataSet;
  411.  
  412. compareds = ds.GetChanges();
  413.  
  414. if (compareds != null)
  415. {
  416. compareds.WriteXml(filename, XmlWriteMode.DiffGram);
  417. }
  418.  
  419. // Write out the contents of tvSample2 to disk
  420.  
  421. filename = Path.Combine(AppPath, "treeview2.xml");
  422.  
  423. if (File.Exists(filename)) { File.Delete(filename); }
  424.  
  425. if (TreeView2.Nodes.Count == ) { return; }
  426.  
  427. row = (DataRow)TreeView2.Nodes[].Tag;
  428.  
  429. ds = row.Table.DataSet;
  430.  
  431. compareds = ds.GetChanges();
  432.  
  433. if (compareds != null)
  434. {
  435. compareds.WriteXml(filename, XmlWriteMode.DiffGram);
  436. }
  437.  
  438. }
  439. catch (Exception err) { UI.ShowError(err.Message); }
  440. finally { UI.Hourglass(false); }
  441. }
  442. #endregion
  443.  
  444. #region tvSample Mouse Down
  445. private void tvSample_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
  446. {
  447.  
  448. TreeViewUtil.SetSelectedNodeByPosition(TreeView1, e.X, e.Y);
  449.  
  450. if (TreeView1.SelectedNode == null) { return; }
  451.  
  452. if (e.Button == MouseButtons.Right) { return; }
  453.  
  454. }
  455. #endregion
  456.  
  457. #region tvSample MouseUp
  458. private void tvSample_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
  459. {
  460.  
  461. switch (e.Button)
  462. {
  463. case MouseButtons.Right:
  464.  
  465. tvSample1Menu.Show(TreeView1, new Point(e.X, e.Y));
  466. return;
  467.  
  468. default:
  469. break;
  470. }
  471.  
  472. }
  473. #endregion
  474.  
  475. #region tvSample2 Mouse Down
  476. private void tvSample2_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
  477. {
  478.  
  479. TreeViewUtil.SetSelectedNodeByPosition(TreeView2, e.X, e.Y);
  480.  
  481. if (TreeView2.SelectedNode == null) { return; }
  482.  
  483. if (e.Button == MouseButtons.Right) { return; }
  484.  
  485. }
  486. #endregion
  487.  
  488. #region tvSample2 MouseUp
  489. private void tvSample2_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
  490. {
  491.  
  492. switch (e.Button)
  493. {
  494. case MouseButtons.Right:
  495.  
  496. tvSample2Menu.Show(TreeView2, new Point(e.X, e.Y));
  497. break;
  498.  
  499. default:
  500. break;
  501. }
  502. }
  503. #endregion
  504.  
  505. #region tvSample Drag And Drop Events
  506. private void tvSample_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e)
  507. {
  508. DoDragDrop(e.Item, DragDropEffects.Move);
  509. }
  510.  
  511. private void tvSample_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
  512. {
  513. TreeViewUtil.DragEnter((TreeView)sender, e);
  514. }
  515.  
  516. private void tvSample_DragOver(object sender, System.Windows.Forms.DragEventArgs e)
  517. {
  518. TreeViewUtil.DragOver((TreeView)sender, e);
  519. }
  520.  
  521. private void tvSample_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
  522. {
  523. DataRow row;
  524. bool dropOnNewControl = false;
  525.  
  526. try
  527. {
  528.  
  529. UI.Hourglass(true);
  530.  
  531. TreeViewUtil.DragDrop((TreeView)sender, e, ref dropOnNewControl);
  532.  
  533. if (dropOnNewControl)
  534. {
  535. row = (DataRow)TreeView2.Nodes[].Tag;
  536. Datas.emp.CommitHierarchy(DBConStr, row.Table.DataSet);
  537. row = (DataRow)TreeView1.Nodes[].Tag;
  538. Datas.emp.CommitHierarchy(DBConStr, row.Table.DataSet);
  539. }
  540.  
  541. // this.LoadAllTrees();
  542.  
  543. UI.Hourglass(false);
  544. }
  545. catch (Exception err) { UI.ShowError(err.Message); }
  546. finally { UI.Hourglass(false); }
  547. }
  548. #endregion
  549.  
  550. #region tvSample2 Drag And Drop Events
  551. private void tvSample2_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e)
  552. {
  553. DoDragDrop(e.Item, DragDropEffects.Move);
  554. }
  555.  
  556. private void tvSample2_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
  557. {
  558. TreeViewUtil.DragEnter((TreeView)sender, e);
  559. }
  560.  
  561. private void tvSample2_DragOver(object sender, System.Windows.Forms.DragEventArgs e)
  562. {
  563. TreeViewUtil.DragOver((TreeView)sender, e);
  564. }
  565.  
  566. private void tvSample2_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
  567. {
  568. DataRow row;
  569. bool dropOnNewControl = false;
  570.  
  571. try
  572. {
  573.  
  574. UI.Hourglass(true);
  575.  
  576. TreeViewUtil.DragDrop((TreeView)sender, e, ref dropOnNewControl);
  577.  
  578. if (dropOnNewControl)
  579. {
  580. row = (DataRow)TreeView1.Nodes[].Tag;
  581. Datas.emp.CommitHierarchy(DBConStr, row.Table.DataSet);
  582. row = (DataRow)TreeView2.Nodes[].Tag;
  583. Datas.emp.CommitHierarchy(DBConStr, row.Table.DataSet);
  584. }
  585.  
  586. UI.Hourglass(false);
  587. }
  588. catch (Exception err) { UI.ShowError(err.Message); }
  589. finally { UI.Hourglass(false); }
  590. }
  591. #endregion
  592.  
  593. #region tvSample1 After Label Edit
  594. private void tvSample_AfterLabelEdit(object sender, System.Windows.Forms.NodeLabelEditEventArgs e)
  595. {
  596. try
  597. {
  598. if (e.Label.Trim().Length < ) { e.CancelEdit = true; }
  599. EditNode(TreeView1.SelectedNode, e.Label);
  600. TreeView1.SelectedNode.EndEdit(false);
  601. TreeView1.LabelEdit = false;
  602. }
  603. catch (Exception err) { UI.ShowError(err.Message); }
  604. }
  605. #endregion
  606.  
  607. #region tvSample2 After Label Edit
  608. private void tvSample2_AfterLabelEdit(object sender, System.Windows.Forms.NodeLabelEditEventArgs e)
  609. {
  610. try
  611. {
  612. if (e.Label.Trim().Length < ) { e.CancelEdit = true; }
  613. EditNode(TreeView2.SelectedNode, e.Label);
  614. TreeView2.SelectedNode.EndEdit(false);
  615. TreeView2.LabelEdit = false;
  616. }
  617. catch (Exception err) { UI.ShowError(err.Message); }
  618. }
  619. #endregion
  620.  
  621. #region tvSample1 Accept Changes
  622. private void button3_Click(object sender, System.EventArgs e)
  623. {
  624.  
  625. DataRow row = null;
  626. UI.Hourglass(true);
  627.  
  628. try
  629. {
  630.  
  631. if (TreeView1.Nodes.Count == ) { return; }
  632.  
  633. row = (DataRow)TreeView1.Nodes[].Tag;
  634.  
  635. Datas.emp.CommitHierarchy(DBConStr, row.Table.DataSet);
  636.  
  637. }
  638. catch (Exception err) { UI.ShowError(err.Message); }
  639. finally { UI.Hourglass(false); }
  640.  
  641. }
  642. #endregion
  643.  
  644. #region tvSample1 拒绝更改 Reject Changes
  645. private void button4_Click(object sender, System.EventArgs e)
  646. {
  647.  
  648. DataRow row = null;
  649. UI.Hourglass(true);
  650.  
  651. try
  652. {
  653.  
  654. if (TreeView1.Nodes.Count < ) { return; }
  655.  
  656. row = (DataRow)TreeView1.Nodes[].Tag;
  657.  
  658. row.Table.DataSet.RejectChanges();
  659.  
  660. LoadTree(TreeView1, row.Table.DataSet);
  661.  
  662. }
  663. catch (Exception err) { UI.ShowError(err.Message); }
  664. finally { UI.Hourglass(false); }
  665. }
  666. #endregion
  667.  
  668. #region tvSample2 接受变化 Accept Changes
  669. private void button6_Click(object sender, System.EventArgs e)
  670. {
  671.  
  672. DataRow row = null;
  673. UI.Hourglass(true);
  674.  
  675. try
  676. {
  677.  
  678. if (TreeView2.Nodes.Count == ) { return; }
  679.  
  680. row = (DataRow)TreeView2.Nodes[].Tag;
  681.  
  682. Datas.emp.CommitHierarchy(DBConStr, row.Table.DataSet);
  683.  
  684. }
  685. catch (Exception err) { UI.ShowError(err.Message); }
  686. finally { UI.Hourglass(false); }
  687. }
  688. #endregion
  689.  
  690. #region tvSample2 Reject Changes
  691. private void button5_Click(object sender, System.EventArgs e)
  692. {
  693.  
  694. DataRow row = null;
  695. UI.Hourglass(true);
  696.  
  697. try
  698. {
  699.  
  700. if (TreeView2.Nodes.Count < ) { return; }
  701.  
  702. row = (DataRow)TreeView2.Nodes[].Tag;
  703.  
  704. row.Table.DataSet.RejectChanges();
  705.  
  706. LoadTree(TreeView2, row.Table.DataSet);
  707.  
  708. }
  709. catch (Exception err) { UI.ShowError(err.Message); }
  710. finally { UI.Hourglass(false); }
  711. }
  712. #endregion
  713.  
  714. #region Form Closed
  715. private void Form1_Closed(object sender, System.EventArgs e)
  716. {
  717.  
  718. }
  719. #endregion
  720.  
  721. #region Exit
  722. private void cmdExit_Click(object sender, System.EventArgs e)
  723. {
  724. this.Close();
  725. Application.Exit();
  726. }
  727. #endregion
  728.  
  729. #region Constructor
  730.  
  731. [STAThread]
  732. static void Main()
  733. {
  734. Application.Run(new Form1());
  735. }
  736.  
  737. public Form1()
  738. {
  739. InitializeComponent();
  740. }
  741.  
  742. protected override void Dispose(bool disposing)
  743. {
  744. if (disposing)
  745. {
  746. if (components != null)
  747. {
  748. components.Dispose();
  749. }
  750. }
  751. base.Dispose(disposing);
  752. }
  753. #endregion
  754.  
  755. #region Windows Form Designer generated code
  756. private void InitializeComponent()
  757. {
  758. this.components = new System.ComponentModel.Container();
  759. this.label1 = new System.Windows.Forms.Label();
  760. this.TreeView1 = new System.Windows.Forms.TreeView();
  761. this.imageList1 = new System.Windows.Forms.ImageList(this.components);
  762. this.button1 = new System.Windows.Forms.Button();
  763. this.button2 = new System.Windows.Forms.Button();
  764. this.TreeView2 = new System.Windows.Forms.TreeView();
  765. this.label2 = new System.Windows.Forms.Label();
  766. this.button3 = new System.Windows.Forms.Button();
  767. this.button4 = new System.Windows.Forms.Button();
  768. this.button5 = new System.Windows.Forms.Button();
  769. this.button6 = new System.Windows.Forms.Button();
  770. this.dataGridView1 = new System.Windows.Forms.DataGridView();
  771. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
  772. this.SuspendLayout();
  773. //
  774. // label1
  775. //
  776. this.label1.Location = new System.Drawing.Point(, );
  777. this.label1.Name = "label1";
  778. this.label1.Size = new System.Drawing.Size(, );
  779. this.label1.TabIndex = ;
  780. this.label1.Text = "Tree 1";
  781. //
  782. // TreeView1
  783. //
  784. this.TreeView1.AllowDrop = true;
  785. this.TreeView1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  786. this.TreeView1.HideSelection = false;
  787. this.TreeView1.ImageIndex = ;
  788. this.TreeView1.ImageList = this.imageList1;
  789. this.TreeView1.Location = new System.Drawing.Point(, );
  790. this.TreeView1.Name = "TreeView1";
  791. this.TreeView1.SelectedImageIndex = ;
  792. this.TreeView1.Size = new System.Drawing.Size(, );
  793. this.TreeView1.TabIndex = ;
  794. this.TreeView1.AfterLabelEdit += new System.Windows.Forms.NodeLabelEditEventHandler(this.tvSample_AfterLabelEdit);
  795. this.TreeView1.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.tvSample_ItemDrag);
  796. this.TreeView1.DragDrop += new System.Windows.Forms.DragEventHandler(this.tvSample_DragDrop);
  797. this.TreeView1.DragEnter += new System.Windows.Forms.DragEventHandler(this.tvSample_DragEnter);
  798. this.TreeView1.DragOver += new System.Windows.Forms.DragEventHandler(this.tvSample_DragOver);
  799. this.TreeView1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tvSample_MouseDown);
  800. this.TreeView1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.tvSample_MouseUp);
  801. //
  802. // imageList1
  803. //
  804. this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
  805. this.imageList1.ImageSize = new System.Drawing.Size(, );
  806. this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
  807. //
  808. // button1
  809. //
  810. this.button1.Location = new System.Drawing.Point(, );
  811. this.button1.Name = "button1";
  812. this.button1.Size = new System.Drawing.Size(, );
  813. this.button1.TabIndex = ;
  814. this.button1.Text = "Reload Test Data";
  815. this.button1.Click += new System.EventHandler(this.button1_Click);
  816. //
  817. // button2
  818. //
  819. this.button2.Location = new System.Drawing.Point(, );
  820. this.button2.Name = "button2";
  821. this.button2.Size = new System.Drawing.Size(, );
  822. this.button2.TabIndex = ;
  823. this.button2.Text = "Save Xml To Root Folder";
  824. this.button2.Click += new System.EventHandler(this.button2_Click);
  825. //
  826. // TreeView2
  827. //
  828. this.TreeView2.AllowDrop = true;
  829. this.TreeView2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  830. this.TreeView2.ImageIndex = ;
  831. this.TreeView2.ImageList = this.imageList1;
  832. this.TreeView2.Location = new System.Drawing.Point(, );
  833. this.TreeView2.Name = "TreeView2";
  834. this.TreeView2.SelectedImageIndex = ;
  835. this.TreeView2.Size = new System.Drawing.Size(, );
  836. this.TreeView2.TabIndex = ;
  837. this.TreeView2.AfterLabelEdit += new System.Windows.Forms.NodeLabelEditEventHandler(this.tvSample2_AfterLabelEdit);
  838. this.TreeView2.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.tvSample2_ItemDrag);
  839. this.TreeView2.DragDrop += new System.Windows.Forms.DragEventHandler(this.tvSample2_DragDrop);
  840. this.TreeView2.DragEnter += new System.Windows.Forms.DragEventHandler(this.tvSample2_DragEnter);
  841. this.TreeView2.DragOver += new System.Windows.Forms.DragEventHandler(this.tvSample2_DragOver);
  842. this.TreeView2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tvSample2_MouseDown);
  843. this.TreeView2.MouseUp += new System.Windows.Forms.MouseEventHandler(this.tvSample2_MouseUp);
  844. //
  845. // label2
  846. //
  847. this.label2.Location = new System.Drawing.Point(, );
  848. this.label2.Name = "label2";
  849. this.label2.Size = new System.Drawing.Size(, );
  850. this.label2.TabIndex = ;
  851. this.label2.Text = "Tree 2";
  852. //
  853. // button3
  854. //
  855. this.button3.Location = new System.Drawing.Point(, );
  856. this.button3.Name = "button3";
  857. this.button3.Size = new System.Drawing.Size(, );
  858. this.button3.TabIndex = ;
  859. this.button3.Text = "Accept Changes";
  860. this.button3.Click += new System.EventHandler(this.button3_Click);
  861. //
  862. // button4
  863. //
  864. this.button4.Location = new System.Drawing.Point(, );
  865. this.button4.Name = "button4";
  866. this.button4.Size = new System.Drawing.Size(, );
  867. this.button4.TabIndex = ;
  868. this.button4.Text = "Reject Changes";
  869. this.button4.Click += new System.EventHandler(this.button4_Click);
  870. //
  871. // button5
  872. //
  873. this.button5.Location = new System.Drawing.Point(, );
  874. this.button5.Name = "button5";
  875. this.button5.Size = new System.Drawing.Size(, );
  876. this.button5.TabIndex = ;
  877. this.button5.Text = "Reject Changes";
  878. this.button5.Click += new System.EventHandler(this.button5_Click);
  879. //
  880. // button6
  881. //
  882. this.button6.Location = new System.Drawing.Point(, );
  883. this.button6.Name = "button6";
  884. this.button6.Size = new System.Drawing.Size(, );
  885. this.button6.TabIndex = ;
  886. this.button6.Text = "Accept Changes";
  887. this.button6.Click += new System.EventHandler(this.button6_Click);
  888. //
  889. // dataGridView1
  890. //
  891. this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  892. this.dataGridView1.Location = new System.Drawing.Point(, );
  893. this.dataGridView1.Name = "dataGridView1";
  894. this.dataGridView1.RowTemplate.Height = ;
  895. this.dataGridView1.Size = new System.Drawing.Size(, );
  896. this.dataGridView1.TabIndex = ;
  897. //
  898. // Form1
  899. //
  900. this.AutoScaleBaseSize = new System.Drawing.Size(, );
  901. this.ClientSize = new System.Drawing.Size(, );
  902. this.Controls.Add(this.dataGridView1);
  903. this.Controls.Add(this.button5);
  904. this.Controls.Add(this.button6);
  905. this.Controls.Add(this.button4);
  906. this.Controls.Add(this.button3);
  907. this.Controls.Add(this.label2);
  908. this.Controls.Add(this.TreeView2);
  909. this.Controls.Add(this.button2);
  910. this.Controls.Add(this.button1);
  911. this.Controls.Add(this.TreeView1);
  912. this.Controls.Add(this.label1);
  913. this.MaximizeBox = false;
  914. this.Name = "Form1";
  915. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  916. this.Text = "Tree Sample";
  917. this.Closed += new System.EventHandler(this.Form1_Closed);
  918. this.Load += new System.EventHandler(this.Form1_Load);
  919. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
  920. this.ResumeLayout(false);
  921.  
  922. }
  923. #endregion
  924.  
  925. }
  926. }

TreeView 拖拽 增删改的更多相关文章

  1. TREEVIEW拖拽对应修改目录

    附件:http://files.cnblogs.com/xe2011/TreeView_Drag_Directory%E6%93%8D%E4%BD%9C.rar     TREEVIEW拖拽对应修改目 ...

  2. C# TreeView 拖拽节点到另一个容器Panel中简单实现

    C# TreeView 拖拽节点到另一个容器Panel中简单实现 用了这么久C#拖拽功能一直没有用到也就没用过,今天因为项目需要,领导特地给我简单讲解了下拖拽功能,真是的大师讲解一点通啊.特地写一篇博 ...

  3. winform 两个TreeView间拖拽节点

    /// <summary> /// 正在拖拽的节点 /// </summary> private TreeNode DragNode = null; /// <summa ...

  4. [译]聊聊C#中的泛型的使用(新手勿入) Seaching TreeVIew WPF 可编辑树Ztree的使用(包括对后台数据库的增删改查) 字段和属性的区别 C# 遍历Dictionary并修改其中的Value 学习笔记——异步 程序员常说的「哈希表」是个什么鬼?

    [译]聊聊C#中的泛型的使用(新手勿入)   写在前面 今天忙里偷闲在浏览外文的时候看到一篇讲C#中泛型的使用的文章,因此加上本人的理解以及四级没过的英语水平斗胆给大伙进行了翻译,当然在翻译的过程中发 ...

  5. Delphi Treeview 用法(概念、属性、添加编辑插入节点、定位节点、拖拽等)

    今天再细研究了一下Treeview的用法,网上虽然总结了很多,但是还是有很多节点没有讲到了,也给使用中遇到很多问题.特地总结一下: 1.概念 Treeview用于显示按照树形结构进行组织的数据.Tre ...

  6. TREEVIEW节点拖拽

    http://files.cnblogs.com/xe2011/TreeView_Drag_and_Drop.rar       假设把A节点往B节点上拖拽 那么  A 为Node1,B为Node2 ...

  7. react之每日一更(实现canvas拖拽,增、删、改拖拽模块大小功能)

    效果图: import React, { Component } from 'react'; import scaleImage from './images/scale.png'; import c ...

  8. SQL你必须知道的-增删改查与约束

    SQL你必须知道的-增删改查与约束   -- 插入数据    --Insert 语句可以省略表名后的列名,但是不推荐    insert into Class values ('' 高一一班 '', ...

  9. mysql实现简单的增删改查,放入xmapp自带数据库中

    1.mysql概念:SQL-Structured Query Language,是一种特殊的语言,专用于操作关系型数据库服务器中的数据,所有的SQL语句分为四类: (1)DDL(2)DQL(3)DML ...

随机推荐

  1. [ Python - 6 ] 正则表达式实现计算器功能

    要求:禁止使用eval函数.参考网上代码如下: #!_*_coding:utf-8_*_ """用户输入计算表达式,显示计算结果""" im ...

  2. 【SQL】数据库更新

    1.插入 INSERT INTO R(A1,A2,...An) VALUES(v1, v2, ...,vn) 如果插入了所有属性,并且按照定义的顺序给出,可以省略(A1,A2,...An) 可以只插入 ...

  3. QPS、TPS、PV等网站业务关键字释义

    QPS:Query Per Second TPS:Transaction Per Second PV:Page View RT:Response Time UV:Unique Visitor DAU: ...

  4. [设计模式-行为型]访问者模式(Vistor)

    一句话 表示一个作用于某对象结构中的各元素的操作.它使你可以在不改变各元素的类的前提下定义作用于这些元素的新操作. 概括

  5. ros pcl sensor::pointcloud2 转换成pcl::pointcloud

    #include <pcl_conversions/pcl_conversions.h> #include <pcl/point_types.h> #include <p ...

  6. 【hdoj_1009】FatMouse's Trade

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1009< 本题用到贪心策略和结构体排序. 问题简化:现有资本M,N个房间,第i个房间对应着价格为F[i ...

  7. 【原创】Maven cobertura整合多个子项目下的单测覆盖率报告

    今天在调试一个UT job的时候发现找不到cobertural报告文件,后来发现在Maven的自项目里找到了对应的代码覆盖率报告,但都是是分散在每个子项目下面的,看起来很不方便.就在想是不是可以把这些 ...

  8. zabbix监控web应用

    1)web应用监控介绍 使用zabbix自带的web场景可以监控url的状态码,响应时间,url的下载速度,非常的棒 思路:定义模板-->创建应用集--->定义web场景--->定义 ...

  9. kotlin 写的一个简单 sql 查询解析器

    package com.dx.efuwu.core import org.apache.commons.lang.StringUtils import java.sql.PreparedStateme ...

  10. 洛谷 P2678 跳石头【经典二分答案/贪心】

    题目描述 这项比赛将在一条笔直的河道中进行,河道中分布着一些巨大岩石.组委会已经选择好了两块岩石作为比赛起点和终点.在起点和终点之间,有 NN 块岩石(不含起点和终点的岩石).在比赛过程中,选手们将从 ...