2011-03-26 50 views
0

我randomperson繼承人我的代碼,它是一個計算器:如何獲取或從我的窗體應用程序搶輸入

namespace WindowsFormsApplication1 
{ 
    partial class Form1 
    { 
     /// <summary> 
     /// Required designer variable. 
     /// </summary> 
     private System.ComponentModel.IContainer components = null; 

     /// <summary> 
     /// Clean up any resources being used. 
     /// </summary> 
     /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 
     protected override void Dispose(bool disposing) 
     { 
      if (disposing && (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.num1 = new System.Windows.Forms.NumericUpDown(); 
      ((System.ComponentModel.ISupportInitialize)(this.num1)).BeginInit(); 
      this.SuspendLayout(); 
      // 
      // num1 
      // 
      this.num1.AccessibleName = ""; 
      this.num1.Location = new System.Drawing.Point(12, 12); 
      this.num1.Name = "num1"; 
      this.num1.Size = new System.Drawing.Size(120, 20); 
      this.num1.TabIndex = 0; 
      // 
      // Form1 
      // 
      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 
      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 
      this.ClientSize = new System.Drawing.Size(284, 262); 
      this.Controls.Add(this.num1); 
      this.Name = "Form1"; 
      this.Text = "Form1"; 
      ((System.ComponentModel.ISupportInitialize)(this.num1)).EndInit(); 
      this.ResumeLayout(false); 

     } 

     #endregion 

     private System.Windows.Forms.NumericUpDown num1; 

    } 
} 
+1

很簡單,得到答案,首先問一個問題。 – manji 2011-03-26 17:19:46

+0

你的問題是什麼? – 2011-03-26 17:20:12

+0

錯誤的代碼。這是設計師。你想什麼時候閱讀輸入?當有人點擊一個按鈕? – 2011-03-26 17:20:18

回答

1

只有在窗體NumericUpDown控件所以我假設你想獲取該控件的該值。你將不得不使用num1.Value來獲得它的價值。

嘗試

protected override void OnLoad(EventArgs e) 
    { 
     base.OnLoad(e); 
     num1.ValueChanged += new EventHandler(numericUpDown1_ValueChanged); 
    } 

    void numericUpDown1_ValueChanged(object sender, EventArgs e) 
    { 
     MessageBox.Show("New value : " +num1.Value); 
    } 
+0

謝謝你 – randomdude 2011-03-26 17:27:05

+0

@randomdude如果你對答案滿意,你應該將問題標記爲已解決。 – Anteru 2011-03-26 17:29:06

+0

我在哪裏把它放在第一個受保護的覆蓋範圍之內void – randomdude 2011-03-26 17:29:42

相關問題