Convert value from Numeric Dropdown to Int : UpDown : GUI Windows Form C# Source Code


Custom Search

C# Source Code » GUI Windows Form » UpDown »

 

Convert value from Numeric Dropdown to Int









    

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

public class Form1 : Form
{

   private System.Windows.Forms.NumericUpDown yearUpDown;
   private System.Windows.Forms.Button calculateButton;
   public Form1() {
      InitializeComponent();
   }
   private void calculateButton_Click( object sender, EventArgs e )
   {
      Console.WriteLine(Convert.ToInt32( yearUpDown.Value ));
   } 
   private void InitializeComponent()
   {
      this.yearUpDown = new System.Windows.Forms.NumericUpDown();
      this.calculateButton = new System.Windows.Forms.Button();
      ((System.ComponentModel.ISupportInitialize)(this.yearUpDown)).BeginInit();
      this.SuspendLayout();

      this.yearUpDown.Location = new System.Drawing.Point(84, 97);
      this.yearUpDown.Maximum = new decimal(new int[] {
            10,
            0,
            0,
            0});
      this.yearUpDown.Minimum = new decimal(new int[] {
            1,
            0,
            0,
            0});
      this.yearUpDown.Name = "yearUpDown";
      this.yearUpDown.ReadOnly = true;
      this.yearUpDown.Size = new System.Drawing.Size(100, 20);
      this.yearUpDown.TabIndex = 5;
      this.yearUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
      this.yearUpDown.Value = new decimal(new int[] {
            1,
            0,
            0,
            0});
      this.calculateButton.Location = new System.Drawing.Point(196, 16);
      this.calculateButton.Name = "calculateButton";
      this.calculateButton.Size = new System.Drawing.Size(75, 23);
      this.calculateButton.TabIndex = 8;
      this.calculateButton.Text = "Calculate";
      this.calculateButton.Click += new System.EventHandler(this.calculateButton_Click);
      // 
      // interestCalculatorForm
      // 
      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
      this.ClientSize = new System.Drawing.Size(289, 288);
      this.Controls.Add(this.calculateButton);
      this.Controls.Add(this.yearUpDown);
      this.Name = "interestCalculatorForm";
      this.Text = "Interest Calculator";
      ((System.ComponentModel.ISupportInitialize)(this.yearUpDown)).EndInit();
      this.ResumeLayout(false);
      this.PerformLayout();

   }

  [STAThread]
  static void Main()
  {
    Application.EnableVisualStyles();
    Application.Run(new Form1());
  }

}



           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo GUI Windows Form
» UpDown