"how to set dialogresult yes in c# custom dialog box" Code Answer's

You're definitely familiar with the best coding language C# that developers use to develop their projects and they get all their queries like "how to set dialogresult yes in c# custom dialog box" answered properly. Developers are finding an appropriate answer about how to set dialogresult yes in c# custom dialog box related to the C# coding language. By visiting this online portal developers get answers concerning C# codes question like how to set dialogresult yes in c# custom dialog box. Enter your desired code related query in the search bar and get every piece of information about C# code related question on how to set dialogresult yes in c# custom dialog box. 

how to set dialogresult yes in c# custom dialog box

By DiodeDiode on May 01, 2021
public void CreateMyForm()
 {
    // Create a new instance of the form.
    Form form1 = new Form();
    // Create two buttons to use as the accept and cancel buttons.
    Button button1 = new Button ();
    Button button2 = new Button ();
   
    // Set the text of button1 to "OK".
    button1.Text = "OK";
    // Set the position of the button on the form.
    button1.Location = new Point (10, 10);
    // Set the text of button2 to "Cancel".
    button2.Text = "Cancel";
    // Set the position of the button based on the location of button1.
    button2.Location 
       = new Point (button1.Left, button1.Height + button1.Top + 10);
    // Make button1's dialog result OK.
    button1.DialogResult = DialogResult.OK;
    // Make button2's dialog result Cancel.
    button2.DialogResult = DialogResult.Cancel;
    // Set the caption bar text of the form.   
    form1.Text = "My Dialog Box";
 
    // Define the border style of the form to a dialog box.
    form1.FormBorderStyle = FormBorderStyle.FixedDialog;
    // Set the accept button of the form to button1.
    form1.AcceptButton = button1;
    // Set the cancel button of the form to button2.
    form1.CancelButton = button2;
    // Set the start position of the form to the center of the screen.
    form1.StartPosition = FormStartPosition.CenterScreen;
    
    // Add button1 to the form.
    form1.Controls.Add(button1);
    // Add button2 to the form.
    form1.Controls.Add(button2);
    
    // Display the form as a modal dialog box.
    form1.ShowDialog();
 
    // Determine if the OK button was clicked on the dialog box.
    if (form1.DialogResult == DialogResult.OK)
    {
       // Display a message box indicating that the OK button was clicked.
       MessageBox.Show("The OK button on the form was clicked.");
       // Optional: Call the Dispose method when you are finished with the dialog box.
       form1.Dispose();
    }
    else
    {
       // Display a message box indicating that the Cancel button was clicked.
       MessageBox.Show("The Cancel button on the form was clicked.");
       // Optional: Call the Dispose method when you are finished with the dialog box.
       form1.Dispose();
    }
 }

Source: docs.microsoft.com

Add Comment

0

All those coders who are working on the C# based application and are stuck on how to set dialogresult yes in c# custom dialog box can get a collection of related answers to their query. Programmers need to enter their query on how to set dialogresult yes in c# custom dialog box related to C# code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about how to set dialogresult yes in c# custom dialog box for the programmers working on C# code while coding their module. Coders are also allowed to rectify already present answers of how to set dialogresult yes in c# custom dialog box while working on the C# language code. Developers can add up suggestions if they deem fit any other answer relating to "how to set dialogresult yes in c# custom dialog box". Visit this developer's friendly online web community, CodeProZone, and get your queries like how to set dialogresult yes in c# custom dialog box resolved professionally and stay updated to the latest C# updates. 

C# answers related to "how to set dialogresult yes in c# custom dialog box"

View All C# queries

C# queries related to "how to set dialogresult yes in c# custom dialog box"

how to set dialogresult yes in c# custom dialog box autoclicker for yes/no in c# indicator ASP.NET Core set update clear cache from IMemoryCache (set by Set method of CacheExtensions class) wpf save file dialog font dialog c# code uinput dialog uwp c# save dialog c# width and height create a dialog in wpf allelrt box wpf aps.net core mvc chek box message box icons c# c# windows forms how to get controls in gropu box a infinite loop in text box update ui c# types of message box C# create project from custom template dotnet custom async return object c# dump custom entity to tracelog dynamics crm 365 ce online c# extension How to save custom class unity mongodb custom IIdGenerator C# Custom setter with parameter custom player spawner mirror vb.net databinding not working on custom property unity c# set gameobject active unity how to set gameobjkect enabled how to set a vector 3 variable in csharp unity set object scale c# private set nodatime instant to datetime off set c# unity set particle properties through script How to set an expiry date on a program c# switch case set value how to set the current user httpcontext.current.user asp.net -mvc unity set parent canvas how to set minvalue of slider in unity unity set sprite image from script unity dynamically set hinge joint spring target position c# form set auto scale how to set the forgound color of listitems in c# c# enum variable set to nonthing unity how to set framrate C# f# set function how to ignore duplicates At least one client secrets (Installed or Web) should be set c# unity set parent to root set current date to textbox in asp.net set bolt variables into c# devexpress aspxdatagridview set VerticalScrollableHeight in codebehind set text in unity invisible how to set the server url in dotnet core unity set terrain to image ef core set identity_insert off set uwp page size when opened c# c# set variable with condition c# set datetime to null value asp.net c# set session timeout HOW TO SET TAG IN SCRIPT UNITY set margin programmatically wpf c# urp set postprocessing value how to set picturebox width with form width in c# c# one line set wpf set button text color get set set active unity object reference not set to an instance of an object vb set only one value in a vector 3 unity

Browse Other Code Languages

CodeProZone