【问题标题】:How to fetch value input from windows form aplication如何从 Windows 窗体应用程序中获取值输入
【发布时间】:2011-03-26 05:37:20
【问题描述】:
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

        }
    }
}

and


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;

    }
}

【问题讨论】:

  • 您究竟需要什么不清楚,请具体说明您需要什么
  • 您能详细说明您要完成的工作吗?代码很有用,但描述您想要做什么以及遇到问题的方式会很有帮助。
  • 现在我需要能够获取输入然后用它来制作计算器,但我不知道如何
  • 总之你想做一个计算器应用
  • 我想做一个命令提示符以外的界面

标签: c# windows visual-studio-2010


【解决方案1】:

您可以在 Form1 类上创建一个公共 getter 函数,该函数访问您需要从中获取值的控件中的值。

【讨论】:

  • Form1 可以有一个类似 public int GetNum() {return num1.Value;} 的方法但是你最好学习一个例子。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-21
  • 1970-01-01
  • 2022-11-30
  • 2018-11-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多