Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

how to input message ox in c#

string input = Interaction.InputBox("Prompt", "Title", "Default", 10, 10);
Comment

how to input message ox in c#

using System;
using System.Windows.Forms;
using System.Drawing;

namespace CustomDialog_Example
{
    class Program
    {
        static void Main(string[] args)
        {
            //Initialize the input variable which will be referenced by the custom input dialog box
            string input = "...";
            //Display the custom input dialog box with the following prompt, window title, and dimensions
            ShowInputDialogBox(ref input, "What is at the end of the rainbow?", "Riddle", 300, 200);

            //Print the input provided by the user
            Console.WriteLine(input);

            Console.ReadLine();

        }

        private static DialogResult ShowInputDialogBox(ref string input, string prompt, string title = "Title", int width = 300, int height = 200)
        {
            //This function creates the custom input dialog box by individually creating the different window elements and adding them to the dialog box

            //Specify the size of the window using the parameters passed
            Size size = new Size(width, height);
            //Create a new form using a System.Windows Form
            Form inputBox = new Form();

            inputBox.FormBorderStyle = FormBorderStyle.FixedDialog;
            inputBox.ClientSize = size;
            //Set the window title using the parameter passed
            inputBox.Text = title;

            //Create a new label to hold the prompt
            Label label = new Label();
            label.Text = prompt;
            label.Location = new Point(5, 5);
            label.Width = size.Width - 10;
            inputBox.Controls.Add(label);

            //Create a textbox to accept the user's input
            TextBox textBox = new TextBox();
            textBox.Size = new Size(size.Width - 10, 23);
            textBox.Location = new Point(5, label.Location.Y + 20);
            textBox.Text = input;
            inputBox.Controls.Add(textBox);

            //Create an OK Button 
            Button okButton = new Button();
            okButton.DialogResult = DialogResult.OK;
            okButton.Name = "okButton";
            okButton.Size = new Size(75, 23);
            okButton.Text = "&OK";
            okButton.Location = new Point(size.Width - 80 - 80, size.Height - 30);
            inputBox.Controls.Add(okButton);

            //Create a Cancel Button
            Button cancelButton = new Button();
            cancelButton.DialogResult = DialogResult.Cancel;
            cancelButton.Name = "cancelButton";
            cancelButton.Size = new Size(75, 23);
            cancelButton.Text = "&Cancel";
            cancelButton.Location = new Point(size.Width - 80, size.Height - 30);
            inputBox.Controls.Add(cancelButton);

            //Set the input box's buttons to the created OK and Cancel Buttons respectively so the window appropriately behaves with the button clicks
            inputBox.AcceptButton = okButton;
            inputBox.CancelButton = cancelButton;

            //Show the window dialog box 
            DialogResult result = inputBox.ShowDialog();
            input = textBox.Text;

            //After input has been submitted, return the input value
            return result;
        }

    }
}
Comment

how to input message ox in c#

using Microsoft.VisualBasic;
Comment

how to input message ox in c#

using System;
using Microsoft.VisualBasic;

namespace VisualBasic_Example
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create the input dialog box with the parameters below
            string input = Interaction.InputBox("What is at the end of the rainbow?", "Riddle", "...", 10, 10);
            
            //After the user has provided input, print to the console
            Console.WriteLine(input);
            Console.ReadLine();

        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: How to determine whether Task.Run is completed within a loop in c# 
Csharp :: C# Action Delegate 
Csharp :: // Force WPF to render UI changes immediately with this magic line of code... 
Csharp :: how to add extra window to wpf 
Csharp :: string.format c# 
Csharp :: Toggle value change 
Csharp :: serach a keyword in whole database 
Csharp :: C# milisecond to h m s 
Csharp :: How to create a gameobject by code 
Csharp :: c# name script 
Csharp :: enumerate dictionary c# 
Csharp :: C# Search in JSON without deserialization 
Csharp :: how to get text color alpha unity 
Csharp :: detect location from ip address .net core 
Csharp :: how to instantiate particle system with a particular rotation 
Csharp :: player movement unity 3d script 
Csharp :: unity phone vibration 
Csharp :: entity framework get all 
Csharp :: C# MemoryStream - Timeouts are not supported on this stream 
Csharp :: store file in DB 
Csharp :: wpf repository pattern query async with includes properties 
Csharp :: how to do if statement based on date in asp net c# 
Csharp :: DateTime2 error in EF Blazor Web Application 
Csharp :: block wapalyzer from detecting codeigniter 
Csharp :: The anti-forgery cookie token and form field token do not match. 
Csharp :: c sharp switch forms 
Csharp :: C# Zip large files causes OOM exception 
Csharp :: asp.net stop page jumping to top on click 
Csharp :: c# expression func automatically select return type 
Csharp :: Jeng InitDb 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =