欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C# 控件屬性和InitializeComponent()關(guān)系案例詳解

 更新時(shí)間:2021年08月27日 16:46:30   作者:劉要直  
這篇文章主要介紹了C# 控件屬性和InitializeComponent()關(guān)系案例詳解,本篇文章通過簡要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下
namespace Test22
{
    partial class Form1
    {
        /// <summary>
        /// 必需的設(shè)計(jì)器變量。
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// 清理所有正在使用的資源。
        /// </summary>
        /// <param name="disposing">如果應(yīng)釋放托管資源,為 true;否則為 false。</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows 窗體設(shè)計(jì)器生成的代碼

        /// <summary>
        /// 設(shè)計(jì)器支持所需的方法 - 不要
        /// 使用代碼編輯器修改此方法的內(nèi)容。
        /// </summary>
        private void InitializeComponent()
        {
            this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
            this.SuspendLayout();
            //
            // numericUpDown1
            //
            this.numericUpDown1.DecimalPlaces = 4;//屬性里對應(yīng)!?。。。?
            this.numericUpDown1.Location = new System.Drawing.Point(12, 12);
            this.numericUpDown1.Name = "numericUpDown1";
            this.numericUpDown1.Size = new System.Drawing.Size(120, 21);
            this.numericUpDown1.TabIndex = 0;
            //
            // Form1
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(153, 53);
            this.Controls.Add(this.numericUpDown1);
            this.Name = "Form1";
            this.Text = "Form1";
            this.Load += new System.EventHandler(this.Form1_Load);
            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.NumericUpDown numericUpDown1;
    }
}

控件中小數(shù)點(diǎn)位數(shù)和InitializeComponent()里面的代碼相呼應(yīng),而下面的代碼又設(shè)置了2,所以覆蓋掉了,代碼和運(yùn)行結(jié)果如下:

using System;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Test22
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            numericUpDown1.Maximum = 20;
            numericUpDown1.Minimum = 1;
            numericUpDown1.DecimalPlaces = 2;
        }
    }
}

到此這篇關(guān)于C# 控件屬性和InitializeComponent()關(guān)系案例詳解的文章就介紹到這了,更多相關(guān)C# 控件屬性和InitializeComponent()關(guān)系內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論