-
大小: 27KB文件类型: .rar金币: 1下载: 0 次发布日期: 2021-05-10
- 语言: C#
- 标签: splitter splittercont 分隔窗口
资源简介
利用splitter控件来实现显示/隐藏左边的控件 ,利用splittercontainer同理可以实现此功能。splitter已被splittercontainer逐步替代,见意用后者来分隔窗口
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace HideSplitter
{
public partial class FormStart : Form
{
TreeView treeView1 = new TreeView();
ListView listView1 = new ListView();
Splitter splitter1 = new Splitter();
ToolTip tt = new ToolTip();
Label l = new Label();
public FormStart()
{
InitializeComponent();
}
private void CreateMySplitControls()
{
treeView1.Dock = Dockstyle.Left;
splitter1.Dock = Dockstyle.Left;
splitter1.MinExtra = 100;
splitter1.MinSize = 75;
splitter1.Width = 3;
splitter1.Height = 300;
l.Text = “3“;
l.AutoSize = true;
l.Location = new Point(-6 splitter1.Height / 2 - l.Height);
l.Font = new System.Drawing.Font(“Marlett“ 9 System.Drawing.Fontstyle.Regular System.Drawing.GraphicsUnit.Point (byte)2);
l.ForeColor = Color.Red;
l.Cursor = Cursors.Hand;
splitter1.Controls.Add(l);
listView1.Dock = Dockstyle.Fill;
treeView1.Nodes.Add(“TreeView Node“);
listView1.Items.Add(“ListView Item“);
tt.SetToolTip(l “隐藏左边的的控件“);
l.Click += new EventHandler(ShowHide);
splitter1.Resize += new EventHandler(splitter_Resize);
this.Controls.AddRange(new Control[] { listView1 splitter1 treeView1 });
}
private void FormStart_Load(object sender EventArgs e)
{
CreateMySplitControls();
}
private void ShowHide(object sender EventArgs e)
{
if (l.Text == “3“)
{
l.Text = “4“;
tt.SetToolTip(l “显示左边的的控件“);
treeView1.Visible = false;
}
else
{
l.Text = “3“;
tt.SetToolTip(l “隐藏左边的的控件“);
treeView1.Visible = true;
}
}
private void splitter_Resize(object o EventArgs e)
{
l.Location = new Point(-6 splitter1.Height / 2 - l.Height);
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2596 2009-09-03 14:19 HideSplitter\HideSplitter\FormStart.cs
文件 1497 2009-09-03 14:19 HideSplitter\HideSplitter\FormStart.Designer.cs
文件 5814 2009-09-03 13:45 HideSplitter\HideSplitter\FormStart.resx
文件 3881 2009-09-03 14:19 HideSplitter\HideSplitter\HideSplitter.csproj
文件 1302 2009-09-03 14:21 HideSplitter\HideSplitter\obj\Debug\HideSplitter.csproj.FileListAbsolute.txt
文件 851 2009-09-03 14:19 HideSplitter\HideSplitter\obj\Debug\HideSplitter.csproj.GenerateResource.Cache
文件 9216 2009-09-03 14:21 HideSplitter\HideSplitter\obj\Debug\HideSplitter.exe
文件 180 2009-09-03 14:19 HideSplitter\HideSplitter\obj\Debug\HideSplitter.FormStart.resources
文件 22016 2009-09-03 14:21 HideSplitter\HideSplitter\obj\Debug\HideSplitter.pdb
文件 180 2009-09-03 14:19 HideSplitter\HideSplitter\obj\Debug\HideSplitter.Properties.Resources.resources
文件 4608 2009-09-03 14:19 HideSplitter\HideSplitter\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll
文件 531 2009-09-03 14:18 HideSplitter\HideSplitter\obj\Debug\test.csproj.FileListAbsolute.txt
文件 970 2009-09-03 13:45 HideSplitter\HideSplitter\obj\Debug\test.csproj.GenerateResource.Cache
文件 497 2009-09-03 14:19 HideSplitter\HideSplitter\Program.cs
文件 1356 2009-09-01 10:05 HideSplitter\HideSplitter\Properties\AssemblyInfo.cs
文件 2848 2009-09-03 14:19 HideSplitter\HideSplitter\Properties\Resources.Designer.cs
文件 5612 2009-09-01 10:05 HideSplitter\HideSplitter\Properties\Resources.resx
文件 1110 2009-09-03 14:19 HideSplitter\HideSplitter\Properties\Settings.Designer.cs
文件 249 2009-09-01 10:05 HideSplitter\HideSplitter\Properties\Settings.settings
文件 926 2009-09-03 14:20 HideSplitter\HideSplitter.sln
..A..H. 12800 2009-09-03 14:21 HideSplitter\HideSplitter.suo
..A..H. 20480 2009-09-03 14:20 HideSplitter\test.suo
目录 0 2009-09-03 14:19 HideSplitter\HideSplitter\obj\Debug\TempPE
目录 0 2009-09-03 14:21 HideSplitter\HideSplitter\obj\Debug
目录 0 2009-09-01 10:05 HideSplitter\HideSplitter\obj
目录 0 2009-09-01 10:05 HideSplitter\HideSplitter\Properties
目录 0 2009-09-03 14:22 HideSplitter\HideSplitter
目录 0 2009-09-03 14:21 HideSplitter
----------- --------- ---------- ----- ----
99520 28
............此处省略1个文件信息
- 上一篇:WPF通过UserControl动态生成向导
- 下一篇:房屋出租系统 ASP.Net
评论
共有 条评论