How do I pass variables to a buttons event method?

前端 未结 8 1815
伪装坚强ぢ
伪装坚强ぢ 2020-12-14 08:29

I need to be able to pass along two objects to the method being fired when I click a button. How do I do this?

So far I\'ve been looking at creating a changed E

8条回答
  •  悲哀的现实
    2020-12-14 09:12

    If you open yourForm.Designer.cs file you will see all the code auto generated by VS. Here you can alter the method called when clicking on the button (or add a second method).

    this.yourButton.Location = new System.Drawing.Point(211, 51);
    this.yourButton.Name = "yourButton";
    this.yourButton.Size = new System.Drawing.Size(75, 23);
    this.yourButton.TabIndex = 0;
    this.yourButton.Text = "yourButton";
    this.yourButton.UseVisualStyleBackColor = true;
    this.yourButton.Click += new System.EventHandler(this.yourMethodHere(object1, object2);
    

    Hope this helps.

提交回复
热议问题