c#获取窗体中所有PictureBox控件,然后存入一个pictureBox集合中,请问怎么实现啊?
解决方案 »
- 在dataGridView上鼠标经过时,会提示,叫什么功能
- 关于网站使用SSL的问题
- 怎么样在gridview中单击某行时高亮显示,只能单击另一行高亮处才能转到另一行````````````
- 如何使发布的程序整合到一个EXE文件中。
- 简单问题:combobox 如何把选中的项的value值传到textbox中
- 请问C#怎样可以监控某进程的IO?
- DataGridView控件禁用点击列头排序
- 关于C#,Delphi和Word一同使用的一个问题
- 为什么我装了VS。NET后管理工具里的IIS找不到了???
- C#.net 高手请进复杂问题困绕(个人意见)
- 中国通用表单生成的问题,请高手指点
- 动态treeview
{
if (c is PictureBox)
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;namespace WindowsApplication7
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button5;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.PictureBox pictureBox3;
private System.Windows.Forms.PictureBox pictureBox4;
private System.Windows.Forms.PictureBox pictureBox5;
private System.Windows.Forms.PictureBox pictureBox6;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null; public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent(); //
// TODO: Add any constructor code after InitializeComponent call
//
} /// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button5 = new System.Windows.Forms.Button();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.pictureBox3 = new System.Windows.Forms.PictureBox();
this.pictureBox4 = new System.Windows.Forms.PictureBox();
this.pictureBox5 = new System.Windows.Forms.PictureBox();
this.pictureBox6 = new System.Windows.Forms.PictureBox();
this.SuspendLayout();
//
// button5
//
this.button5.Location = new System.Drawing.Point(344, 284);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(120, 76);
this.button5.TabIndex = 4;
this.button5.Text = "button5";
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(24, 52);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(80, 32);
this.pictureBox1.TabIndex = 5;
this.pictureBox1.TabStop = false;
//
// pictureBox2
//
this.pictureBox2.Location = new System.Drawing.Point(20, 112);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(76, 28);
this.pictureBox2.TabIndex = 6;
this.pictureBox2.TabStop = false;
//
// pictureBox3
//
this.pictureBox3.Location = new System.Drawing.Point(20, 192);
this.pictureBox3.Name = "pictureBox3";
this.pictureBox3.TabIndex = 7;
this.pictureBox3.TabStop = false;
//
// pictureBox4
//
this.pictureBox4.Location = new System.Drawing.Point(172, 60);
this.pictureBox4.Name = "pictureBox4";
this.pictureBox4.TabIndex = 8;
this.pictureBox4.TabStop = false;
//
// pictureBox5
//
this.pictureBox5.Location = new System.Drawing.Point(164, 156);
this.pictureBox5.Name = "pictureBox5";
this.pictureBox5.TabIndex = 9;
this.pictureBox5.TabStop = false;
//
// pictureBox6
//
this.pictureBox6.Location = new System.Drawing.Point(168, 244);
this.pictureBox6.Name = "pictureBox6";
this.pictureBox6.TabIndex = 10;
this.pictureBox6.TabStop = false;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(492, 406);
this.Controls.Add(this.pictureBox6);
this.Controls.Add(this.pictureBox5);
this.Controls.Add(this.pictureBox4);
this.Controls.Add(this.pictureBox3);
this.Controls.Add(this.pictureBox2);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.button5);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false); }
#endregion /// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
} private void Form1_Load(object sender, System.EventArgs e)
{ } private void button5_Click(object sender, System.EventArgs e)
{
int iPB = 0;
foreach(System.Windows.Forms.Control c in this.Controls)
{
if(c is PictureBox)
{
iPB++;
}
}
PictureBox[] pbs = new PictureBox[iPB] ;
iPB = 0;
foreach(System.Windows.Forms.Control c in this.Controls)
{
if(c is PictureBox)
{
pbs[iPB] = (PictureBox)c;
iPB++;
}
}
}
}
}
private void button5_Click(object sender, System.EventArgs e)
{
int iPB = 0;
foreach(System.Windows.Forms.Control c in this.Controls)
{
if(c is PictureBox)
{
iPB++;
}
}
PictureBox[] pbs = new PictureBox[iPB] ;
iPB = 0;
foreach(System.Windows.Forms.Control c in this.Controls)
{
if(c is PictureBox)
{
pbs[iPB] = (PictureBox)c;
iPB++;
}
}
}
{
if(this.Controls[i] is PictureBox)
//加入数组
}
private void button5_Click(object sender, System.EventArgs e)
{
ArrayList pics=new ArrayList();
foreach(System.Windows.Forms.Control c in this.Controls)
{
if(c is PictureBox)
pics.Add(c);
}
}