问题1:我想动态声明一组label,并且同时还要添加onclick事件,onclick根据不同的label做不同的事
问题2:label是放在一个panel上的,panel设有背景图,但是不能拉伸,郁闷死,放一个picturebox发现又把label给挡住了,
请问大家又什么好得办法,多谢
问题2:label是放在一个panel上的,panel设有背景图,但是不能拉伸,郁闷死,放一个picturebox发现又把label给挡住了,
请问大家又什么好得办法,多谢
解决方案 »
- C# WPF程序 在旗舰版win7可运行,专业版win7死活不行,求助!
- C#链接问题
- 问俩问题
- join连接查询得到的数据表如何保存?急
- 紧急求助,请各位路过的高手帮小弟解决一下,在线等!
- 关于“返回”的问题!
- datagrid.ReadOnly=True,如何做到编辑datagrid中选中的某一行,其他行为只读
- 请问那有inside C# 第二版的中文版。tom archer著。
- 如何将源码中的代码,一下全折起来?
- 使用AxWebBrowser点击链接的时候,如何在地址栏中显示当前的url呀?
- winform如何部署与打包,生成.exe或msi文件。还有关于三层架构打包的事情
- C#中CheckListBox如何与数据库的表绑定 ?
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;namespace Miner
{
/// <summary>
/// Summary des cription for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel panel1;
/// <summary>
/// Required designer variable.
/// </summary>
/// private Button[] n =new Button[100];
private int[] kn=new int[100]; 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.panel1 = new System.Windows.Forms.Panel();
this.SuspendLayout();
//
// panel1
//
this.panel1.Location = new System.Drawing.Point(8, 8);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(400, 400);
this.panel1.TabIndex = 0;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(416, 413);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.panel1});
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)
{
int a=0;
int x=0,y=0;
for (a=0;a<=99;a++)
{
n[a] = new Button();
n[a].BackColor =Color.White;
n[a].FlatStyle = FlatStyle.Flat;
n[a].Width = panel1.Width / 10;
n[a].Left = x * n[a].Width;
n[a].Height = panel1.Height / 10;
n[a].Top = y * n[a].Height;
n[a].Name = "b" + a;
panel1.Controls.Add(n[a]);
panel1.Controls[a].MouseDown += new MouseEventHandler(this.ButtonArray_OnClick);
x += 1;
if (x == 10)
{
x = 0;
y += 1;
}
} } private void ButtonArray_OnClick(object sender, MouseEventArgs e)
{
MouseEventArgs arg=(MouseEventArgs)e;
Button b1=(Button)sender;
if (arg.Button==MouseButtons.Right )
b1.BackColor=Color.White ;
else
{
//b1.BackColor =Color.White ;
b1.Image=Image.FromFile("f:\\my documents\\my pictures\\elements\\regular_smile.gif");
}
}
}
}
运行时写上:
Label1.BringToFront();
在.net应用程序中使用用户控件
http://blog.csdn.net/zhzuo/archive/2004/11/30/199599.aspx