c#之splitcontainer类(接口)

c#之splitcontainer类(接口)tcbs系统中用到,故大约了解下用法:http://msdn.microsoft.com/zh-cn/library/system.windows.forms.splitcontainer.aspx下面的代码示例演示…

大家好,又见面了,我是你们的朋友全栈君。

 tcbs系统中用到,故大约了解下用法:


http://msdn.microsoft.com/zh-cn/library/system.windows.forms.splitcontainer.aspx

下面的代码示例演示一个垂直的和一个水平的 SplitContainer。 垂直拆分器以 10 个像素的增量移动。 该垂直 SplitContainer 的左面板包含一个 TreeView 控件,其右面板包含一个水平 SplitContainer。 水平 SplitContainer 的两个面板都填充 ListView 控件,上面的面板定义为一个 FixedPanel,所以当调整容器大小时其大小不会调整。 移动垂直拆分器将引发 SplitterMoving 事件,在本示例中表现为光标样式发生变化。 在停止移动拆分器时引发 SplitterMoved 事件。 本示例中通过将光标样式还原为默认样式来表示它。

VB

C#

C++

F#

JScript

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

public class Form1 : System.Windows.Forms.Form

{

    private System.Windows.Forms.SplitContainer splitContainer1;

    private System.Windows.Forms.TreeView treeView1;

    private System.Windows.Forms.SplitContainer splitContainer2;

    private System.Windows.Forms.ListView listView2;

    private System.Windows.Forms.ListView listView1;

    public Form1()

    {

    InitializeComponent();

    }

    private void InitializeComponent()

    {

        splitContainer1 = new System.Windows.Forms.SplitContainer();

        treeView1 = new System.Windows.Forms.TreeView();

        splitContainer2 = new System.Windows.Forms.SplitContainer();

        listView1 = new System.Windows.Forms.ListView();

        listView2 = new System.Windows.Forms.ListView();

        splitContainer1.SuspendLayout();

        splitContainer2.SuspendLayout();

        SuspendLayout();

        // Basic SplitContainer properties.

        // This is a vertical splitter that moves in 10-pixel increments.

        // This splitter needs no explicit Orientation property because Vertical is the default.

        splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;

        splitContainer1.ForeColor = System.Drawing.SystemColors.Control;

        splitContainer1.Location = new System.Drawing.Point(0, 0);

        splitContainer1.Name = “splitContainer1”;

        // You can drag the splitter no nearer than 30 pixels from the left edge of the container.

        splitContainer1.Panel1MinSize = 30;

        // You can drag the splitter no nearer than 20 pixels from the right edge of the container.

        splitContainer1.Panel2MinSize = 20;

        splitContainer1.Size = new System.Drawing.Size(292, 273);

        splitContainer1.SplitterDistance = 79;

        // This splitter moves in 10-pixel increments.

        splitContainer1.SplitterIncrement = 10;

        splitContainer1.SplitterWidth = 6;

        // splitContainer1 is the first control in the tab order.

        splitContainer1.TabIndex = 0;

        splitContainer1.Text = “splitContainer1”;

        // When the splitter moves, the cursor changes shape.

        splitContainer1.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(splitContainer1_SplitterMoved);

        splitContainer1.SplitterMoving += new System.Windows.Forms.SplitterCancelEventHandler(splitContainer1_SplitterMoving);

        // Add a TreeView control to the left panel.

        splitContainer1.Panel1.BackColor = System.Drawing.SystemColors.Control;

        // Add a TreeView control to Panel1.

        splitContainer1.Panel1.Controls.Add(treeView1);

        splitContainer1.Panel1.Name = “splitterPanel1”;

        // Controls placed on Panel1 support right-to-left fonts.

        splitContainer1.Panel1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;

        // Add a SplitContainer to the right panel.

        splitContainer1.Panel2.Controls.Add(splitContainer2);

        splitContainer1.Panel2.Name = “splitterPanel2”;

        // This TreeView control is in Panel1 of splitContainer1.

        treeView1.Dock = System.Windows.Forms.DockStyle.Fill;

        treeView1.ForeColor = System.Drawing.SystemColors.InfoText;

        treeView1.ImageIndex = -1;

        treeView1.Location = new System.Drawing.Point(0, 0);

        treeView1.Name = “treeView1”;

        treeView1.SelectedImageIndex = -1;

        treeView1.Size = new System.Drawing.Size(79, 273);

        // treeView1 is the second control in the tab order.

        treeView1.TabIndex = 1;

        // Basic SplitContainer properties.

        // This is a horizontal splitter whose top and bottom panels are ListView controls. The top panel is fixed.

        splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;

        // The top panel remains the same size when the form. is resized.

        splitContainer2.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;

        splitContainer2.Location = new System.Drawing.Point(0, 0);

        splitContainer2.Name = “splitContainer2”;

        // Create the horizontal splitter.

        splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;

        splitContainer2.Size = new System.Drawing.Size(207, 273);

        splitContainer2.SplitterDistance = 125;

        splitContainer2.SplitterWidth = 6;

        // splitContainer2 is the third control in the tab order.

        splitContainer2.TabIndex = 2;

        splitContainer2.Text = “splitContainer2”;

        // This splitter panel contains the top ListView control.

        splitContainer2.Panel1.Controls.Add(listView1);

        splitContainer2.Panel1.Name = “splitterPanel3”;

        // This splitter panel contains the bottom ListView control.

        splitContainer2.Panel2.Controls.Add(listView2);

        splitContainer2.Panel2.Name = “splitterPanel4”;

        // This ListView control is in the top panel of splitContainer2.

        listView1.Dock = System.Windows.Forms.DockStyle.Fill;

        listView1.Location = new System.Drawing.Point(0, 0);

        listView1.Name = “listView1”;

        listView1.Size = new System.Drawing.Size(207, 125);

        // listView1 is the fourth control in the tab order.

        listView1.TabIndex = 3;

        // This ListView control is in the bottom panel of splitContainer2.

        listView2.Dock = System.Windows.Forms.DockStyle.Fill;

        listView2.Location = new System.Drawing.Point(0, 0);

        listView2.Name = “listView2”;

        listView2.Size = new System.Drawing.Size(207, 142);

        // listView2 is the fifth control in the tab order.

        listView2.TabIndex = 4;

        // These are basic properties of the form.

        ClientSize = new System.Drawing.Size(292, 273);

        Controls.Add(splitContainer1);

        Name = “Form1”;

        Text = “Form1”;

        splitContainer1.ResumeLayout(false);

        splitContainer2.ResumeLayout(false);

        ResumeLayout(false);

    }

    [STAThread]

    static void Main()

    {

        Application.Run(new Form1());

    }

    private void splitContainer1_SplitterMoving(System.Object sender, System.Windows.Forms.SplitterCancelEventArgs e)

    {

    // As the splitter moves, change the cursor type.

    Cursor.Current = System.Windows.Forms.Cursors.NoMoveVert;

    }

    private void splitContainer1_SplitterMoved(System.Object sender, System.Windows.Forms.SplitterEventArgs e)

    {

    // When the splitter stops moving, change the cursor back to the default.

    Cursor.Current=System.Windows.Forms.Cursors.Default;

    }

}

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9240380/viewspace-706035/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/9240380/viewspace-706035/

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/161077.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • oidc auth2.0_使用Spring Security 5.0和OIDC轻松构建身份验证「建议收藏」

    oidc auth2.0_使用Spring Security 5.0和OIDC轻松构建身份验证「建议收藏」oidcauth2.0“我喜欢编写身份验证和授权代码。”〜从来没有Java开发人员。厌倦了一次又一次地建立相同的登录屏幕?尝试使用OktaAPI进行托管身份验证,授权和多因素身份验证。SpringSecurity不仅是一个功能强大且可高度自定义的身份验证和访问控制框架,它还是保护基于Spring的应用程序的实际标准。从前,SpringSecurity需要使用大量的XML来…

  • Ubuntu Mobile Demo at IDF Shanghai (英文)

    Ubuntu Mobile Demo at IDF Shanghai (英文)

  • Logistic 回归算法原理[通俗易懂]

    Logistic 回归算法原理[通俗易懂]Logistic回归算法原理Sigmoid函数概率决策分布函数函数求导逻辑回归模型概率预测函数对数几率回归条件概率分布极大似然估计似然函数对数似然对数损失梯度上升Logistic回归,又名逻辑回归,它从线性回归发展而来,是一种广义的线性回归模型;该模型预测输出的是样本类别的条件概率分布,因而可以取概率值最大的类别作为分类结果,实质上是一个分类模型。Sigmoid函数概率决策首先来看一个实际应用场景下的分类问题:某电商网站有着大量的商品,当用户看到这些商品时,有两个选择,一是点击,二是不点击。

  • lua学习之table类型

    关系表类型,这是一个很强大的类型。我们可以把这个类型看作是一个数组。只是 C语言的数组,只能用正整数来作索引; 在Lua中,你可以用任意类型的值来作数组的索引,但这个值不能是&#1

    2021年12月25日
  • 【Android】PreferenceFragment「建议收藏」

    【Android】PreferenceFragment「建议收藏」调用PreferenceFragment类出错,用了我三天时间才搞定,查官方文档,看百度最后在这位大佬的帖子帮助下终于搞定了。https://blog.csdn.net/cqx13763055264/article/details/78498419#commentBoxPreferenceActivity创建和使用比较复杂,Android官方现在不建议使用了,使用Preferenc…

  • java下载文件_java下载文件到本地[通俗易懂]

    java下载文件_java下载文件到本地[通俗易懂]//获取文件路径并创建一个出入流StringfilePath=”文件实际路径”;FileInputStreamfis=newFileInputStream(filePath);//创建输出流,向客户端输出数据ServletOutputStreamsos=response.getOutputStream();//获取文件名StringfileName=filePath.subs…

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号