设为首页
加入收藏
联系我们
首页 基础教程 技术文档 实例分析 数 据 库 疑难杂症 ASP.NET 七夕许愿树 技术论坛
同学网,基于同学关系的真实社区
<%-- 最新动态 Begin --%> <%-- 最新动态 End --%>
最新文章
 C#摄像头编程实例
 C#下用P2P技术实现点…
 Asp.net(c#)数…
 SQL Server数据…
 .NET牛人应该知道些什…
 NET牛人应该知道些什么
 SQL Server S…
 备份指定表到另一数据库
 SQLSERVER中快速…
 ASP.NET中url传…
 ASP.NET自动给UR…
 ASP.NET 2.0防…
 ASP.NET 2.0 …
 如何解决ASP.net中…
 sql server 与…
<%-- 最新动态 Begin --%> <%-- 最新动态 End --%>
推荐文章
 关于C#中的REF和黓认…
 读书笔记c#高级编程 委…
 【算法】C#快速排序类
 Visual C#的SQ…
 C#中调用API
 Infragistics…
 C#接口转换
 C#读取设备信息
 用.net操作word
 C# MessageBo…
 Visual C#中的数…
 雅虎公司C#笔试题,看看…
 C#.NET使用NHib…
 .net学习之运算符重载…
 Visual C# 3.…
<%-- 最新动态 Begin --%> <%-- 最新动态 End --%>
热门文章
 ADO.Net与ADO在…
 开发ASP.NET下的M…
 用C#+XMI技术进行U…
 什么是虚拟机?
 C#基础全接触
 C#学习第一天
 雅虎公司C#笔试题,看看…
 C#语言初级入门(1)
 C#中利用正则表达式实现…
 远程重启计算机(C#)
 用.net操作word
 什么是B/S三层?
 VB和C# 语法对比图 …
 Visual C#常用函…
 Visual C#的SQ…
C#中动态创建控件及事件处理程序
阅读正文 文字大小:增大 减小  文字行距:增大 减小   双击自动滚屏
本文由中国C#技术学习中心整理  如果你对本文有不明之处请到技术论坛讨论!

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" );
            }
            
        }
    }
}


本文由中国C#技术学习中心整理  如果你对本文有不明之处请到技术论坛讨论!

中国C#技术交流QQ群:6337034  10976424  9383681  35248582  35248645
版权所有:中国C#技术学习中心 Copyright ? 2006-2008
建议浏览分辨率使用:1024*768分辨率
粤ICP备05002251号