Separator control splitter demo

Source: Internet
Author: User

Using System;
Using System. Drawing;
Using System. Collections;
Using System. ComponentModel;
Using System. Windows. Forms;
Using System. Data;

Namespace SplitWindow
{
/// <Summary>
/// Summary of Form1.
/// </Summary>
Public class Form1: System. Windows. Forms. Form
{
P rivate System. Windows. Forms. PictureBox pictureBox1;
P rivate System. Windows. Forms. Splitter splitter1;
P rivate System. Windows. Forms. RichTextBox richTextBox1;
P rivate System. Windows. Forms. Splitter splitter2;
P rivate System. Windows. Forms. ListView listView1;
P rivate System. Windows. Forms. ColumnHeader columnHeader1;
P rivate system. Windows. Forms. columnheader columnheader2;
P rivate system. Windows. Forms. columnheader columnheader3;
/// <Summary>
/// Required designer variables.
/// </Summary>
P rivate system. componentmodel. Container components = NULL;

Public form1 ()
{
//
// Required for Windows Form Designer support
//
Initializecomponent ();

//
// Todo: add Any constructor code after initializecomponent calls
//
}

/// <Summary>
/// Clear all resources in use.
/// </Summary>
Protected override void Dispose (bool disposing)
{
If (disposing)
{
If (components! = Null)
{
Components. Dispose ();
}
}
Base. Dispose (disposing );
}

# Region code generated by Windows Form Designer
/// <Summary>
/// The designer supports the required methods-do not use the code editor to modify
/// Content of this method.
/// </Summary>
P rivate void InitializeComponent ()
{
System. ComponentModel. ComponentResourceManager resources = new System. ComponentModel. ComponentResourceManager (typeof (Form1 ));
This. pictureBox1 = new System. Windows. Forms. PictureBox ();
This. splitter1 = new System. Windows. Forms. Splitter ();
This. richTextBox1 = new System. Windows. Forms. RichTextBox ();
This. splitter2 = new System. Windows. Forms. Splitter ();
This. listView1 = new System. Windows. Forms. ListView ();
This. columnheader1 = new system. Windows. Forms. columnheader ();
This. columnheader2 = new system. Windows. Forms. columnheader ();
This. columnheader3 = new system. Windows. Forms. columnheader ();
(System. componentmodel. isupportinitialize) (This. picturebox1). begininit ();
This. suspendlayout ();
//
// Picturebox1
//
This. picturebox1.dock = system. Windows. Forms. dockstyle. Top;
This. picturebox1.image = (system. Drawing. Image) (resources. GetObject ("picturebox1.image ")));
This. picturebox1.location = new system. Drawing. Point (0, 0 );
This. picturebox1.name = "picturebox1 ";
This. picturebox1.size = new system. Drawing. Size (344,128 );
This. picturebox1.sizemode = system. Windows. Forms. pictureboxsizemode. stretchimage;
This. picturebox1.tabindex = 0;
This. pictureBox1.TabStop = false;
//
// Splitter1
//
This. splitter1.Cursor = System. Windows. Forms. Cursors. heatmap;
This. splitter1.Dock = System. Windows. Forms. DockStyle. Top;
This. splitter1.Location = new System. Drawing. Point (0,128 );
This. splitter1.MinExtra = 0;
This. splitter1.Name = "splitter1 ";
This. splitter1.Size = new System. Drawing. Size (344, 3 );
This. splitter1.TabIndex = 1;
This. splitter1.TabStop = false;
//
// RichTextBox1
//
This. richTextBox1.Dock = System. Windows. Forms. DockStyle. Left;
This. richTextBox1.Location = new System. Drawing. Point (0,131 );
This. richTextBox1.Name = "richTextBox1 ";
This. richTextBox1.Size = new System. Drawing. Size (120, 75 );
This. richTextBox1.TabIndex = 2;
This. richTextBox1.Text = "";
//
// Splitter2
//
This. splitter2.Location = new System. Drawing. Point (120,131 );
This. splitter2.Name = "splitter2 ";
This. splitter2.Size = new System. Drawing. Size (3, 75 );
This. splitter2.TabIndex = 3;
This. splitter2.TabStop = false;
//
// ListView1
//
This. listview1.columns. addrange (new system. Windows. Forms. columnheader [] {
This. columnheader1,
This. columnheader2,
This. columnheader3 });
This. listview1.dock = system. Windows. Forms. dockstyle. Fill;
This. listview1.fullrowselect = true;
This. listview1.gridlines = true;
This. listview1.location = new system. Drawing. Point (123,131 );
This. listview1.name = "listview1 ";
This. listview1.size = new system. Drawing. Size (221, 75 );
This. listview1.tabindex = 4;
This. listview1.usecompatiblestateimagebehavior = false;
This. listview1.view = system. Windows. Forms. View. details;
This. listview1.selectedindexchanged + = new system. eventhandler (this. listview1_selectedindexchanged );
//
// ColumnHeader1
//
This. columnHeader1.Text = "name ";
This. columnHeader1.Width = 40;
//
// ColumnHeader2
//
This. columnHeader2.Text = "title ";
//
// ColumnHeader3
//
This. columnHeader3.Text = "Address ";
This. columnHeader3.Width = 150;
//
// Form1
//
This. AutoScaleBaseSize = new System. Drawing. Size (6, 14 );
This. ClientSize = new System. Drawing. Size (344,206 );
This. Controls. Add (this. listView1 );
This. Controls. Add (this. splitter2 );
This. Controls. Add (this. richTextBox1 );
This. Controls. Add (this. splitter1 );
This. Controls. Add (this. pictureBox1 );
This. Name = "Form1 ";
This. StartPosition = System. Windows. Forms. FormStartPosition. CenterScreen;
This. Text = "demonstrate how to use the separation control ";
This. Load + = new System. EventHandler (this. form#load );
(System. ComponentModel. ISupportInitialize) (this. pictureBox1). EndInit ();
This. ResumeLayout (false );

}
# Endregion

/// <Summary>
/// Main entry point of the application.
/// </Summary>
[STAThread]
Static void Main ()
{
Application. Run (new Form1 ());
}

P rivate void Form1_Load (object sender, System. EventArgs e)
{
Int itemNumber = this. listView1.Items. Count;
String [] subItem0 = {"Zhang Ying", "sales representative", "No. 245, Fuxingmen "};
This. listview1.items. insert (itemnumber, new listviewitem (subitem0 ));
This. listview1.items [itemnumber]. imageindex = 0;
String [] subitem1 = {"Wang Wei", "vice president", "Rome garden No. 890 "};
This. listview1.items. insert (itemnumber, new listviewitem (subitem1 ));
This. listview1.items [itemnumber]. imageindex = 1;
String [] subitem2 = {"Li Fang", "sales representative", "78 Shaoyuan community "};
This. listview1.items. insert (itemnumber, new listviewitem (subitem2 ));
This. listview1.items [itemnumber]. imageindex = 2;
}

P rivate void listview1_selectedindexchanged (Object sender, system. eventargs E)
{
Try
{
ListViewItem MyItem = this. listView1.SelectedItems [0];
Switch (MyItem. Text)
{
Case "Zhang Ying ":
This. richTextBox1.Text = "Bachelor of psychology from Peking University. She also completed the "cold food art ". Zhang Ying is a member of the International Food Association. ";
Bitmap SrcBitmap1 = new Bitmap ("EMPID1.bmp ");
This. pictureBox1.Image = SrcBitmap1;
Break;
Case "Wang Wei ":
This. richTextBox1.Text = "Wang Wei received a bachelor's degree in Business from Nanjing University and a doctorate in international marketing from the school. He can speak fluent French and Italian and can read German. He joined the company as a sales representative and was promoted to a sales manager and vice president of sales. Wang Wei is a member of the sales management round-table Association, the Beijing Business Association, and the Pacific Ocean Import Association. ";
Bitmap SrcBitmap2 = new Bitmap ("EMPID2.bmp ");
This. pictureBox1.Image = SrcBitmap2;
Break;
Case "Li Fang ":
This. richTextBox1.Text = "Li Fang received a bachelor's degree in chemistry from Beijing University. She also completed the food retail management qualification program. Li Fang was hired as a salesman and promoted to a sales representative. ";
Bitmap SrcBitmap3 = new Bitmap ("EMPID3.bmp ");
This. pictureBox1.Image = SrcBitmap3;
Break;
}
}
Catch (Exception Err)
{
}
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.