/// <summary> /// 设置TreeView选中节点 /// </summary> /// <param name="treeView"></param> /// <param name="selectStrName">选中节点name</param> public static void SelectTreeView(TreeViewEx treeView, string selectStrName) { treeView.Focus(); TreeNode[] selectnode = treeView.Nodes.Find(IsNullToString(selectStrName), true); if (selectnode != null && selectnode.Length > 0) { treeView.SelectedNode = selectnode[0];//选中 if (selectnode[0].Parent != null) { selectnode[0].Parent.Expand();//展开父级 } } //for (int i = 0; i < treeView.Nodes.Count; i++) //{ // for (int j = 0; j < treeView.Nodes[i].Nodes.Count; j++) // { // if (treeView.Nodes[i].Nodes[j].Name == selectStrName) // { // treeView.SelectedNode = treeView.Nodes[i].Nodes[j];//选中 // //treeView.Nodes[i].Nodes[j].Checked = true; // treeView.Nodes[i].Expand();//展开父级 // return; // } // } //} }
public void BeginEdit() { if (/*treeView.toolkitWindow != null*/true) { if (!treeView.LabelEdit) { throw new Exception("SWF_TreeNodeLabelEditFalse"); } if (!treeView.Focused) { treeView.Focus(); } treeView.BeginEdit(this); } }
/// <summary> /// 设置TreeView选中节点 /// </summary> /// <param name="treeView"></param> /// <param name="selectStrName">选中节点name</param> public static void SelectTreeView(TreeViewEx treeView, string selectStrName) { treeView.Focus(); for (int i = 0; i < treeView.Nodes.Count; i++) { for (int j = 0; j < treeView.Nodes[i].Nodes.Count; j++) { if (treeView.Nodes[i].Nodes[j].Name == selectStrName) { treeView.SelectedNode = treeView.Nodes[i].Nodes[j]; //选中 //treeView.Nodes[i].Nodes[j].Checked = true; treeView.Nodes[i].Expand(); //展开父级 return; } } } }
/// <summary> /// 设置TreeView选中节点 /// </summary> /// <param name="treeView"></param> /// <param name="selectStrName">选中节点name</param> public static void SelectTreeView(TreeViewEx treeView, string selectStrName) { treeView.Focus(); for (int i = 0; i < treeView.Nodes.Count; i++) { for (int j = 0; j < treeView.Nodes[i].Nodes.Count; j++) { if (treeView.Nodes[i].Nodes[j].Name == selectStrName) { treeView.SelectedNode = treeView.Nodes[i].Nodes[j];//选中 //treeView.Nodes[i].Nodes[j].Checked = true; treeView.Nodes[i].Expand();//展开父级 return; } } } }
/// <summary> /// 设置TreeView选中节点 /// </summary> /// <param name="treeView"></param> /// <param name="selectStrName">选中节点name</param> public static void SelectTreeView(TreeViewEx treeView, string selectStrName) { treeView.Focus(); TreeNode[] selectnode = treeView.Nodes.Find(IsNullToString(selectStrName), true); if (selectnode != null && selectnode.Length > 0) { treeView.SelectedNode = selectnode[0];//选中 if (selectnode[0].Parent != null) selectnode[0].Parent.Expand();//展开父级 } //for (int i = 0; i < treeView.Nodes.Count; i++) //{ // for (int j = 0; j < treeView.Nodes[i].Nodes.Count; j++) // { // if (treeView.Nodes[i].Nodes[j].Name == selectStrName) // { // treeView.SelectedNode = treeView.Nodes[i].Nodes[j];//选中 // //treeView.Nodes[i].Nodes[j].Checked = true; // treeView.Nodes[i].Expand();//展开父级 // return; // } // } //} }
/// <summary> /// 左侧菜单状态 折叠 展开 选中 未选 /// </summary> /// <param name="pname">展开的功能名称name(二级菜单)</param> /// <param name="threeMenu">三级菜单</param> public void LeftMenuState(string pname, string threeMenu) { int Pleft_panelHeight = panel_MainHeight; //panel的高度 if (this.Controls.Count > 0) { int Pleft_panel_count = this.Controls.Count; // -1; //二级菜单个数 int Pleft_panel_item_height = Pleft_panelHeight - (Pleft_panel_count * item_top_height) + item_top_height; //二级菜单高度-展开的 int tvex_height = Pleft_panel_item_height - item_top_height; //菜单列表高度-展开的 int next_top = 0; int i = 0; foreach (PanelEx ctl in this.Controls) { PanelEx ctl_top = ctl.Controls.Find("top_" + ctl.Name, true)[0] as PanelEx; ctl.Width = LeftWidth; ctl_top.Width = LeftWidth; //ctl_top.Height=item_top_height; if (ctl.Controls.Find("ibtn_" + ctl.Name, true).Count() > 0) { ImageButton ibtn = ctl_top.Controls.Find("ibtn_" + ctl.Name, true)[0] as ImageButton; TreeViewEx tvex = ctl.Controls.Find("tv_" + ctl.Name, true)[0] as TreeViewEx; ibtn.Left = LeftWidth - ibtn.Width - 1; tvex.Width = LeftWidth; if (ctl.Name == pname) { ctl.Height = Pleft_panel_item_height; tvex.Visible = true; tvex.Height = tvex_height; if (tvex.GetNodeCount(true) > 0) { for (int j = 0; j < tvex.Nodes.Count; j++) { if (tvex.Nodes[j].Name == threeMenu) { tvex.Focus(); //tvex.Nodes[j].BackColor = Color.FromArgb(51, 153, 255); tvex.SelectedNode = tvex.Nodes[j]; //选中 break; } //else //{ // //未选中 // tvex.Nodes[j].BackColor = Color.White; //} } } ibtn.BackgroundImage = ServiceStationClient.Skin.Properties.Resources.ico_delete; ibtn.Tag = "1"; } else { if (pname == "" && i == 0) { ctl.Height = Pleft_panel_item_height; tvex.Visible = true; tvex.Height = tvex_height; ibtn.BackgroundImage = ServiceStationClient.Skin.Properties.Resources.ico_delete; ibtn.Tag = "1"; } else { ctl.Height = item_top_height; tvex.Visible = true; tvex.Height = 0; ibtn.BackgroundImage = ServiceStationClient.Skin.Properties.Resources.ico_add; ibtn.Tag = "0"; } } } else { ctl.Height = item_top_height; PictureBox pb = ctl_top.Controls.Find("pb_" + ctl.Name, true)[0] as PictureBox; pb.Left = LeftWidth - pb.Width - 1; if (ctl.Name == pname) { pb.Image = null; //ctl_top.BackColor = Color.FromArgb(255, 255, 0, 0); } else if (ctl.Name == threeMenu) { pb.Image = null; //ctl_top.BackColor = Color.FromArgb(255, 255, 0, 0); } else { pb.Image = null; //ctl_top.BackColor = Color.FromArgb(233, 243, 253); } ctl_top.Refresh(); } ctl.Top = next_top; next_top += ctl.Height; i++; } } }
/// <summary> /// 左侧菜单状态 折叠 展开 选中 未选 /// </summary> /// <param name="pname">展开的功能名称name(二级菜单)</param> /// <param name="threeMenu">三级菜单</param> public void LeftMenuState(string pname, string threeMenu) { int Pleft_panelHeight = panel_MainHeight;//panel的高度 if (this.Controls.Count > 0) { int Pleft_panel_count = this.Controls.Count; // -1; //二级菜单个数 int Pleft_panel_item_height = Pleft_panelHeight - (Pleft_panel_count * item_top_height) + item_top_height; //二级菜单高度-展开的 int tvex_height = Pleft_panel_item_height - item_top_height; //菜单列表高度-展开的 int next_top = 0; int i = 0; foreach (Panel ctl in this.Controls) { PanelEx ctl_top = ctl.Controls.Find("top_" + ctl.Name, false)[0] as PanelEx; ctl.Width = LeftWidth + 3; ctl_top.Width = LeftWidth + 3; if (ctl_top.Controls.ContainsKey("ibtn_" + ctl.Name)) { ImageButton ibtn = ctl_top.Controls.Find("ibtn_" + ctl.Name, false)[0] as ImageButton; TreeViewEx tvex = ctl.Controls.Find("tv_" + ctl.Name, false)[0] as TreeViewEx; ibtn.Left = LeftWidth - ibtn.Width - 5; tvex.Width = LeftWidth + 3; if (ctl.Name == pname) { ctl.Height = Pleft_panel_item_height; tvex.Visible = true; tvex.Height = tvex_height; if (tvex.GetNodeCount(true) > 0) { for (int j = 0; j < tvex.Nodes.Count; j++) { if (tvex.Nodes[j].Name == threeMenu) { tvex.Focus(); //tvex.Nodes[j].BackColor = Color.FromArgb(51, 153, 255); tvex.SelectedNode = tvex.Nodes[j];//选中 break; } } } ibtn.BackgroundImage = ServiceStationClient.Skin.Properties.Resources.Menu_Collapse_V; ibtn.Tag = "1"; } else { ctl_top.BackColor = _normalColor; if (pname == "" && i == 0) { ctl.Height = Pleft_panel_item_height; tvex.Visible = true; tvex.Height = tvex_height; ibtn.BackgroundImage = ServiceStationClient.Skin.Properties.Resources.Menu_Collapse_V; ibtn.Tag = "1"; } else { ctl.Height = item_top_height; tvex.Visible = true; tvex.Height = 0; ibtn.BackgroundImage = ServiceStationClient.Skin.Properties.Resources.Menu_Expand_V; ibtn.Tag = "0"; } } } else { ctl.Height = item_top_height; if (ctl.Name != pname) { ctl_top.BackColor = _normalColor; } } ctl.Top = next_top; next_top += ctl.Height; i++; } } }