且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 WPF 用户控件(带按钮的文本框)中触发单击事件?

更新时间:2021-08-01 08:23:55

因为我们已经创建了 UserControl1.然后在添加 Click 事件之后 UserControl1.Desginer.cs 文件将如下所示.

As we have created the UserControl1.then after adding the Click event the UserControl1.Desginer.cs file will look like this.

  private void InitializeComponent()
        {
            this.button1 = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(180, 38);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(75, 23);
            this.button1.TabIndex = 0;
            this.button1.Text = "button1";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            // 
            // UserControl1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Controls.Add(this.button1);
            this.Name = "UserControl1";
            this.Size = new System.Drawing.Size(286, 95);
            this.ResumeLayout(false);

        }

并且在 UserControl1.cs 文件中会有按钮点击事件的主体

and in the UserControl1.cs file will have the body of the Button click event

private void button1_Click(object sender, EventArgs e)
        {

        }

这可能对你有帮助.请告诉我

this may help you.Plz let me know