All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
C#中SplitContainer控件应用实例

Writer: qq Article type: Programming skills(编程技巧) Time: 2014/7/11 9:18:03 Browse times: 366 Comment times: 0

C#中SplitContainer控件应用实例


Head photo

Go homepage
Upload pictures
Write articles

C#中SplitContainer控件应用实例

SplitContainer控件
功能
SplitContainer控件被看作是一个复合体,它是由一个可移动的拆分条分隔的两个面板。当鼠标指针悬停在该拆分条上时,指针将相应地呈现为灰度校正状,以显示该拆分条是可移动的。图1所示为SplitContainer控件。

图1 SplitContainer控件
2.属性
SplitContainer控件常用属性及说明如表1所示。

表1 SplitContainer控件常用属性及说明
下面详细介绍Orientation属性,该属性用于确定拆分器的方向,而不是确定控件自身的方向。
语法:
public Orientation Orientation { get; set; }
属性值:Orientation值之一。默认为Vertical。Orientation指定控件或控件元素的方向。当值为Horizontal时,水平放置控件或元素;当值为Verticalt时,垂直放置控件或元素,默认为此选项。
示例
Orientation属性的使用
本示例中,当程序运行时,单击【Orientation属性】按钮,设置Orientation属性为Horizontal,使控件水平排列。网站源代码示例运行结果如图2所示。

Orientation属性
程序主要代码如下:
private void button1_Click(object sender, EventArgs e)
{
this.splitContainer1.Orientation= Orientation.Horizontal;
}
完整程序代码如下:
★★★★★主程序文件完整程序代码★★★★★
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace _8_21
{
static class Program
{
///

本教程来自http://www.isstudy.com/
/// 应用程序的主入口点。
///

[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmSplitContainer());
}
}
}
★★★★★frmSplitContainer窗体设计文件完整程序代码★★★★★
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace _8_21
{
public partial class frmSplitContainer : Form
{
public frmSplitContainer()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.splitContainer1.Orientation= Orientation.Horizontal;
}
private void button2_Click(object sender, EventArgs e)
{
this.splitContainer1.FixedPanel = FixedPanel.Panel1;
}
private void button3_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void frmSplitContainer_Load(object sender, EventArgs e)
{
}
}
}
★★★★frmSplitContainer窗体代码文件完整程序代码★★★★★
namespace _8_21
{
partial class frmSplitContainer
{
/// 本教程来自http://www.isstudy.com/
/// 必需的设计器变量。
///

private System.ComponentModel.IContainer components = null;
///
/// 清理所有正在使用的资源。
///

/// 如果应释放托管资源,为 true;否则为 false。
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
///
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。网站源代码
///

private void InitializeComponent()
{
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.button1 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();




There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.