using System;
using System.Windows.Forms;
namespace MifuminLib
{
///
/// 数値入力ダイアログボックス v1.00
/// http://tgws.fromc.jp/dl/numberinputbox/
///
public class NumberInputBox : Form
{
///
/// 数値入力ダイアログを開きます。
///
/// オーナーフォーム
/// 表示するメッセージ
/// 入力の最小値
/// 入力の最大値
/// 初期状態で表示される数値
/// 入力された数値(キャンセルされた場合はvalue)
static public decimal Show(IWin32Window owner, string message, decimal minimum, decimal maximum, decimal value)
{
NumberInputBox form = new NumberInputBox();
form.Text = message;
form.numericUpDown1.Minimum = minimum;
form.numericUpDown1.Maximum = maximum;
form.numericUpDown1.Value = value;
if (form.ShowDialog(owner) == DialogResult.OK)
{
return form.numericUpDown1.Value;
}
else
{
return value;
}
}
private NumberInputBox()
{
InitializeComponent();
}
private void NumberInputBox_Load(object sender, EventArgs e)
{
numericUpDown1.Select(0, numericUpDown1.ToString().Length);
}
///
/// 必要なデザイナ変数です。
///
private System.ComponentModel.IContainer components = null;
///
/// 使用中のリソースをすべてクリーンアップします。
///
/// マネージ リソースが破棄される場合 true、破棄されない場合は false です。
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows フォーム デザイナで生成されたコード
///
/// デザイナ サポートに必要なメソッドです。このメソッドの内容を
/// コード エディタで変更しないでください。
///
private void InitializeComponent()
{
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.btnOK = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
this.SuspendLayout();
//
// numericUpDown1
//
this.numericUpDown1.Location = new System.Drawing.Point(12, 12);
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.Size = new System.Drawing.Size(199, 19);
this.numericUpDown1.TabIndex = 0;
this.numericUpDown1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.numericUpDown1.ThousandsSeparator = true;
//
// btnOK
//
this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btnOK.Location = new System.Drawing.Point(217, 12);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(76, 19);
this.btnOK.TabIndex = 1;
this.btnOK.Text = "OK";
this.btnOK.UseVisualStyleBackColor = true;
//
// btnCancel
//
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(299, 12);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(61, 19);
this.btnCancel.TabIndex = 2;
this.btnCancel.Text = "キャンセル";
this.btnCancel.UseVisualStyleBackColor = true;
//
// NumberInputBox
//
this.AcceptButton = this.btnOK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(372, 43);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.numericUpDown1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "NumberInputBox";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "NumberInputBox";
this.Load += new System.EventHandler(this.NumberInputBox_Load);
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.NumericUpDown numericUpDown1;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Button btnCancel;
}
}