当前位置: 首页>>代码示例>>C#>>正文


C# NumericUpDown.ThousandsSeparator属性代码示例

本文整理汇总了C#中System.Windows.Forms.NumericUpDown.ThousandsSeparator属性的典型用法代码示例。如果您正苦于以下问题:C# NumericUpDown.ThousandsSeparator属性的具体用法?C# NumericUpDown.ThousandsSeparator怎么用?C# NumericUpDown.ThousandsSeparator使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在System.Windows.Forms.NumericUpDown的用法示例。


在下文中一共展示了NumericUpDown.ThousandsSeparator属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InstantiateMyNumericUpDown

public void InstantiateMyNumericUpDown()
{
   // Create and initialize a NumericUpDown control.
   numericUpDown1 = new NumericUpDown();

   // Dock the control to the top of the form.
   numericUpDown1.Dock = System.Windows.Forms.DockStyle.Top;

   // Set the Minimum, Maximum, and initial Value.
   numericUpDown1.Value = 5;
   numericUpDown1.Maximum = 2500;
   numericUpDown1.Minimum = -100;
   
   // Add the NumericUpDown to the Form.
   Controls.Add(numericUpDown1);
}

// Check box to toggle decimal places to be displayed.
private void checkBox1_Click(Object sender,
                             EventArgs e)
{
   /* If DecimalPlaces is greater than 0, set them to 0 and round the 
      current Value; otherwise, set DecimalPlaces to 2 and change the 
      Increment to 0.25. */
   if (numericUpDown1.DecimalPlaces > 0)
   {
      numericUpDown1.DecimalPlaces = 0;
      numericUpDown1.Value = Decimal.Round(numericUpDown1.Value, 0);
   }
   else
   {
      numericUpDown1.DecimalPlaces = 2;
      numericUpDown1.Increment = 0.25M;
   }
}

// Check box to toggle thousands separators to be displayed.
private void checkBox2_Click(Object sender,
                             EventArgs e)
{   
   /* If ThousandsSeparator is true, set it to false; 
      otherwise, set it to true. */
   if (numericUpDown1.ThousandsSeparator)
   {
      numericUpDown1.ThousandsSeparator = false;
   }
   else
   {
      numericUpDown1.ThousandsSeparator = true;
   }
}

// Check box to toggle hexadecimal to be displayed.
private void checkBox3_Click(Object sender, 
                             EventArgs e)
{
   /* If Hexadecimal is true, set it to false; 
      otherwise, set it to true. */    
   if (numericUpDown1.Hexadecimal)
   {
      numericUpDown1.Hexadecimal = false;
   }
   else
   {
      numericUpDown1.Hexadecimal = true;
   }
}
开发者ID:.NET开发者,项目名称:System.Windows.Forms,代码行数:67,代码来源:NumericUpDown.ThousandsSeparator

示例2: UpDownForm

//引入命名空间
using System;
  using System.Drawing;
  using System.Collections;
  using System.ComponentModel;
  using System.Windows.Forms;
  using System.Data;

  public class UpDownForm : System.Windows.Forms.Form
  {
    private System.Windows.Forms.Label lblCurrSel;
    private System.Windows.Forms.Button btnGetSelections;
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.NumericUpDown numericUpDown;

    public UpDownForm()
    {
      InitializeComponent();
    }
    private void InitializeComponent()
    {
      this.label1 = new System.Windows.Forms.Label ();
      this.numericUpDown = new System.Windows.Forms.NumericUpDown ();
      this.btnGetSelections = new System.Windows.Forms.Button ();
      this.lblCurrSel = new System.Windows.Forms.Label ();
      numericUpDown.BeginInit ();

      label1.Location = new System.Drawing.Point (8, 80);
      label1.Text = "Numeric UpDown Control";
      label1.Size = new System.Drawing.Size (232, 32);
      label1.Font = new System.Drawing.Font ("Verdana", 12);
      label1.TabIndex = 3;
      numericUpDown.Location = new System.Drawing.Point (264, 80);
      numericUpDown.Maximum = new decimal (5000);
      numericUpDown.Size = new System.Drawing.Size (168, 20);
      numericUpDown.ThousandsSeparator = true;
      numericUpDown.TabIndex = 1;
      numericUpDown.UpDownAlign = System.Windows.Forms.LeftRightAlignment.Left;
      numericUpDown.ValueChanged += new System.EventHandler (this.numericUpDown_ValueChanged);

      btnGetSelections.Location = new System.Drawing.Point (16, 136);
      btnGetSelections.Size = new System.Drawing.Size (136, 24);
      btnGetSelections.TabIndex = 4;
      btnGetSelections.Text = "Get Current Selections";
      btnGetSelections.Click += new System.EventHandler (this.btnGetSelections_Click);
      lblCurrSel.Location = new System.Drawing.Point (176, 120);
      lblCurrSel.Size = new System.Drawing.Size (256, 48);
      this.Text = "Spin Controls";
      this.AutoScaleBaseSize = new System.Drawing.Size (5, 13);
      this.ClientSize = new System.Drawing.Size (448, 181);
      this.Controls.Add (this.lblCurrSel);
      this.Controls.Add (this.btnGetSelections);
      this.Controls.Add (this.label1);
      this.Controls.Add (this.numericUpDown);
      numericUpDown.EndInit ();
    }
    static void Main() 
    {
      Application.Run(new UpDownForm());
    }

    protected void numericUpDown_ValueChanged (object sender, System.EventArgs e)
    {
      this.Text = "You changed the numeric value...";
    }

    protected void btnGetSelections_Click (object sender, System.EventArgs e)
    {
      lblCurrSel.Text =  "Number: " 
        + numericUpDown.Value;
    }
  }
开发者ID:C#程序员,项目名称:System.Windows.Forms,代码行数:72,代码来源:NumericUpDown.ThousandsSeparator


注:本文中的System.Windows.Forms.NumericUpDown.ThousandsSeparator属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。