示例:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace ToolTipTest
{
///
/// Form1 的摘要说明。
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel panel1;
private System.ComponentModel.IContainer components;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
///
/// 清理所有正在使用的资源。
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
///
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
///
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.SuspendLayout();
//
// panel1
//
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(736, 273);
this.panel1.TabIndex = 0;
this.panel1.SizeChanged += new System.EventHandler(this.panel1_SizeChanged);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(736, 273);
this.Controls.Add(this.panel1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
///
/// 应用程序的主入口点。
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private PictureBox[] p =new PictureBox[100];
private void Form1_Load(object sender, System.EventArgs e)
{
for(int i=0;i
完全填充this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
固定的话只有计算位置了
pictureBox1.Location = new System.Drawing.Point((pictureBox1.Parent.Size.Width - pictureBox1.Size.Width) / 2, (pictureBox1.Parent.Size.Height - pictureBox1.Size.Height) / 2);
非固定可能是这个
位置你可以自己算出来,大概是
picturebox.Top=(panel.Height-picturebox.Height)/2;
pictureboxT.Left=(panel.Width-picturebox.Width)/2;