| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 522 人关注过本帖
标题:图形组件的应用
只看楼主 加入收藏
王杰
Rank: 2
等 级:新手上路
威 望:4
帖 子:307
专家分:0
注 册:2005-5-13
收藏
 问题点数:0 回复次数:2 
图形组件的应用

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

namespace picturebox
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.ComboBox comboBox1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();

//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox4 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(16, 96);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(256, 144);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(56, 24);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(24, 21);
this.textBox1.TabIndex = 1;
this.textBox1.Text = "";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(88, 24);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(24, 21);
this.textBox2.TabIndex = 2;
this.textBox2.Text = "";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(56, 56);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(24, 21);
this.textBox3.TabIndex = 3;
this.textBox3.Text = "";
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(88, 56);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(24, 21);
this.textBox4.TabIndex = 4;
this.textBox4.Text = "";
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(40, 23);
this.label1.TabIndex = 5;
this.label1.Text = "位置";
//
// label2
//
this.label2.Location = new System.Drawing.Point(8, 56);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(32, 16);
this.label2.TabIndex = 6;
this.label2.Text = "大小";
//
// label3
//
this.label3.Location = new System.Drawing.Point(184, 24);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(64, 16);
this.label3.TabIndex = 7;
this.label3.Text = "显示模式";
//
// button1
//
this.button1.Location = new System.Drawing.Point(120, 56);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(56, 23);
this.button1.TabIndex = 8;
this.button1.Text = "确定";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// comboBox1
//
this.comboBox1.Items.AddRange(new object[] {
"Normal",
"StretchImage",
"AutoSize",
"CenterImage"});
this.comboBox1.Location = new System.Drawing.Point(192, 56);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(80, 20);
this.comboBox1.TabIndex = 9;
this.comboBox1.Text = "请选择显示的模式";
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.pictureBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void button1_Click(object sender, System.EventArgs e)
{
if ((textBox1.Text !="")&&(textBox2.Text !="")&&(textBox3.Text !="")&&(textBox4.Text !=""))
{
int x,y;
x=Convert.ToInt32(textBox1.Text);
y=Convert.ToInt32(textBox2.Text);
pictureBox1.Location=new Point(x,y);
x=Convert.ToInt32(textBox3.Text);
y=Convert.ToInt32(textBox4.Text);
pictureBox1.Size=new Size(x,y);
}
}

private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (comboBox1.SelectedIndex ==0)
pictureBox1.SizeMode=PictureBoxSizeMode.Normal;
if (comboBox1.SelectedIndex ==1)
pictureBox1.SizeMode=PictureBoxSizeMode.StretchImage;
if (comboBox1.SelectedIndex ==2)
pictureBox1.SizeMode=PictureBoxSizeMode.AutoSize;
if (comboBox1.SelectedIndex ==3)
pictureBox1.SizeMode=PictureBoxSizeMode.CenterImage;
}
}
}

搜索更多相关主题的帖子: 图形 组件 应用 
2005-11-11 18:12
consam
Rank: 1
等 级:新手上路
帖 子:46
专家分:0
注 册:2005-11-9
收藏
得分:0 
这个程序so easy!!!!!
2005-11-12 18:56
consam
Rank: 1
等 级:新手上路
帖 子:46
专家分:0
注 册:2005-11-9
收藏
得分:0 

有什么问题吗??

有就值说吗??

2005-11-12 18:56
快速回复:图形组件的应用
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022179 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved