OK, this is messing me up, and I can not understand what's wrong ...
I have made two forms, the first form just has a simple button on it, which opens another like a dialog:
using (form 2f = new form 2 ()) {if (f.ShowDialog ()! = DialogResult.OK) MessageBox.Show ("Not OK"); Other messageboxes Show ("OK"); }
Second, which is Form2
, there are two buttons on it. What I have done is to set AcceptButton form for everyone, and CancelButton in the other should be necessary in order to make all this work in my head. But when I run this, I click on the button that opens Form 2. Now I can click on a set as CancelButton, and I get the "Not OK" message box. But when I click on a set as AcceptButton, nothing happens? The code for InitializeComponent Form2 looks like this:
private zeros starting object () {this.button1 = new system.indo.form.button (); This.button2 = new system.window.form. button (); This.SuspendLayout (); // // button1 // it.button1 Location = new system Drawing.Point (211, 13); 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; // // button2 / this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel; This.button2.Location = New system. Drawing Points (130, 13); This.button2.Name = "button2"; This.button2.Size = New system. Example. Size (75, 23); This.button2.TabIndex = 1; This.button2.Text = "button2"; This.button2.UseVisualStyleBackColor = True; // // // Form 2 // AcceptButton = this.button1; this. Etoscale comments = new system Drawing. Size F (6f, 13f); This.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this. Cancon Button = It. Button 2; This.ClientSize = new system.downling Size (298, 59); This.Controls.Add (this.button2); This.Controls.Add (this.button1); This.Name = "Form2"; this. Text = "form2"; This.Load + = New system. Event Handler (this.Form2_Load); This.ResumeLayout (wrong); }
I have not done anything by adding those two buttons, and set AcceptButton and CancelButton why does not it work? Setting AcceptButton / CancelButton is not enough, it just indicates that enter
Comments
Post a Comment