当前位置:编程学习 > C#/ASP.NET >>

带有小计算器的TextBox控件

答案:
/*hycapril@sohu.com

需要的添加的控件,  

  private System.Windows.Forms.TextBox textBox1;
  private System.Windows.Forms.Panel panel1;
  private System.Windows.Forms.Button B_1;
  private System.Windows.Forms.Button B_N1;
  private System.Windows.Forms.Button B_N2;
  private System.Windows.Forms.Button B_N3;
  private System.Windows.Forms.Button B_N4;
  private System.Windows.Forms.Button B_N5;
  private System.Windows.Forms.Button B_N6;
  private System.Windows.Forms.Button B_N7;
  private System.Windows.Forms.Button B_N8;
  private System.Windows.Forms.Button B_N9;
  private System.Windows.Forms.Button B_N0;
  private System.Windows.Forms.Button B_ok;
  private System.Windows.Forms.Button B_Cancel;
  private System.Windows.Forms.Button B_J;
  private System.Windows.Forms.Button B_JJ;
  private System.Windows.Forms.Button B_C;
  private System.Windows.Forms.Button B_CC;
  private System.Windows.Forms.Button B_D;
  private System.Windows.Forms.Button B_B;

*/

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

namespace TextBoxControl
{
 /// <summary>
 /// TextBoxControl 的摘要说明。
 /// 带有小计算器的TextBox控件。
 /// hycapril 2005 04 06制作。
 /// </summary>

 public class TextBoxControl : System.Windows.Forms.UserControl
 {
  private System.Windows.Forms.TextBox textBox1;
  private System.Windows.Forms.Panel panel1;
  private System.Windows.Forms.Button B_1;
  private System.Windows.Forms.Button B_N1;
  private System.Windows.Forms.Button B_N2;
  private System.Windows.Forms.Button B_N3;
  private System.Windows.Forms.Button B_N4;
  private System.Windows.Forms.Button B_N5;
  private System.Windows.Forms.Button B_N6;
  private System.Windows.Forms.Button B_N7;
  private System.Windows.Forms.Button B_N8;
  private System.Windows.Forms.Button B_N9;
  private System.Windows.Forms.Button B_N0;
  private System.Windows.Forms.Button B_ok;
  private System.Windows.Forms.Button B_Cancel;
  private System.Windows.Forms.Button B_J;
  private System.Windows.Forms.Button B_JJ;
  private System.Windows.Forms.Button B_C;
  private System.Windows.Forms.Button B_CC;
  private System.Windows.Forms.Button B_D;
  private System.Windows.Forms.Button B_B;
  /// <summary>
  /// 必需的设计器变量。
  /// </summary>
  private System.ComponentModel.Container components = null;

  public TextBoxControl()
  {
   // 该调用是 Windows.Forms 窗体设计器所必需的。
   InitializeComponent();

   // TODO: 在 InitComponent 调用后添加任何初始化

  }

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

  #region 组件设计器生成的代码
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器
  /// 修改此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {
   System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(TextBoxControl));
   this.textBox1 = new System.Windows.Forms.TextBox();
   this.B_1 = new System.Windows.Forms.Button();
   this.panel1 = new System.Windows.Forms.Panel();
   this.B_B = new System.Windows.Forms.Button();
   this.B_D = new System.Windows.Forms.Button();
   this.B_CC = new System.Windows.Forms.Button();
   this.B_C = new System.Windows.Forms.Button();
   this.B_JJ = new System.Windows.Forms.Button();
   this.B_J = new System.Windows.Forms.Button();
   this.B_Cancel = new System.Windows.Forms.Button();
   this.B_N0 = new System.Windows.Forms.Button();
   this.B_N9 = new System.Windows.Forms.Button();
   this.B_N8 = new System.Windows.Forms.Button();
   this.B_N7 = new System.Windows.Forms.Button();
   this.B_N6 = new System.Windows.Forms.Button();
   this.B_N5 = new System.Windows.Forms.Button();
   this.B_N4 = new System.Windows.Forms.Button();
   this.B_N3 = new System.Windows.Forms.Button();
   this.B_N2 = new System.Windows.Forms.Button();
   this.B_N1 = new System.Windows.Forms.Button();
   this.B_ok = new System.Windows.Forms.Button();
   this.panel1.SuspendLayout();
   this.SuspendLayout();
   //
   // textBox1
   //
   this.textBox1.Location = new System.Drawing.Point(0, 0);
   this.textBox1.Name = "textBox1";
   this.textBox1.Size = new System.Drawing.Size(96, 21);
   this.textBox1.TabIndex = 0;
   this.textBox1.Text = "";
   this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
   //
   // B_1
   //
   this.B_1.BackColor = System.Drawing.SystemColors.ControlLightLight;
   this.B_1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
   this.B_1.Image = ((System.Drawing.Image)(resources.GetObject("B_1.Image")));
   this.B_1.Location = new System.Drawing.Point(96, 0);
   this.B_1.Name = "B_1";
   this.B_1.Size = new System.Drawing.Size(18, 20);
   this.B_1.TabIndex = 1;
   this.B_1.Click += new System.EventHandler(this.button1_Click);
   //
   // panel1
   //
   this.panel1.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
   this.panel1.Controls.Add(this.B_B);
   this.panel1.Controls.Add(this.B_D);
   this.panel1.Controls.Add(this.B_CC);
   this.panel1.Controls.Add(this.B_C);
   this.panel1.Controls.Add(this.B_JJ);
   this.panel1.Controls.Add(this.B_J);
   this.panel1.Controls.Add(this.B_Cancel);
   this.panel1.Controls.Add(this.B_N0);
   this.panel1.Controls.Add(this.B_N9);
   this.panel1.Controls.Add(this.B_N8);
   this.panel1.Controls.Add(this.B_N7);
   this.panel1.Controls.Add(this.B_N6);
   this.panel1.Controls.Add(this.B_N5);
   this.panel1.Controls.Add(this.B_N4);
   this.panel1.Controls.Add(this.B_N3);
   

上一个:一个使用用户控件(包括组件)的演示
下一个:在WEB自定义控件中实现事件及自动保存值

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,