Click here to Skip to main content
15,896,405 members
Home / Discussions / C#
   

C#

 
QuestionModal window Pin
fififlowertot19-Jan-11 23:26
fififlowertot19-Jan-11 23:26 
AnswerRe: Modal window Pin
DaveyM6920-Jan-11 0:55
professionalDaveyM6920-Jan-11 0:55 
AnswerRe: Modal window Pin
#realJSOP20-Jan-11 4:44
professional#realJSOP20-Jan-11 4:44 
AnswerRe: Modal window Pin
Paladin200020-Jan-11 7:50
Paladin200020-Jan-11 7:50 
GeneralRe: Modal window Pin
OriginalGriff20-Jan-11 8:29
mveOriginalGriff20-Jan-11 8:29 
GeneralRe: Modal window Pin
Paladin200020-Jan-11 8:41
Paladin200020-Jan-11 8:41 
GeneralRe: Modal window Pin
OriginalGriff21-Jan-11 1:30
mveOriginalGriff21-Jan-11 1:30 
GeneralRe: Modal window Pin
Paladin200021-Jan-11 3:18
Paladin200021-Jan-11 3:18 
From what I was reading, it looked like he was asking a question similar to this one. Perhaps he wasn't, my mistake.

The purpose of the static class is to give it "MessageBox-like" usage; e.g., you don't have to use "new MessageBox()" to instantiate that dialog, you can simply call one of the "MessageBox.Show()" overloads.


Regardless, the code I listed above is not thread safe. Sniff | :^) Here would be a better version:

public partial class Input : Form
{
    public Input()
    {
        InitializeComponent();
    }

    public Input(string caption, string defaultValue) : this()
    {
        this.Text = caption;
        textBox1.Text = defaultValue;
    }

    public string StringValue
    {
        get { return textBox1.Text; }
        set { textBox1.Text = value; }
    }
    }

public static class InputBox
{
    public static DialogResult ShowDialog(string caption, ref string value)
    {
        Input inForm = new Input(caption, value);

        if (inForm.ShowDialog() == DialogResult.OK)
        {
            value = inForm.StringValue;
            return DialogResult.OK;
        }
        return DialogResult.Cancel;
    }
}


And a usage example (with threads):

private void button1_Click(object sender, EventArgs e)
{
    new Thread(new ParameterizedThreadStart(doMessage)).Start("one");
    new Thread(new ParameterizedThreadStart(doMessage)).Start("two");
}

private void doMessage(object msg)
{
    string x = msg.ToString();
    if (InputBox.ShowDialog("Test", ref x) == DialogResult.OK) MessageBox.Show(x);
}

GeneralRe: Modal window Pin
OriginalGriff21-Jan-11 5:12
mveOriginalGriff21-Jan-11 5:12 
AnswerRe: Modal window Pin
RaviRanjanKr23-Jan-11 17:50
professionalRaviRanjanKr23-Jan-11 17:50 
QuestionIncrease Execution time for Sp in webconfig for time out problem Pin
Mugdha_Aditya19-Jan-11 23:06
Mugdha_Aditya19-Jan-11 23:06 
AnswerRe: Increase Execution time for Sp in webconfig for time out problem Pin
TweakBird19-Jan-11 23:52
TweakBird19-Jan-11 23:52 
GeneralRe: Increase Execution time for Sp in webconfig for time out problem Pin
Mugdha_Aditya19-Jan-11 23:56
Mugdha_Aditya19-Jan-11 23:56 
GeneralRe: Increase Execution time for Sp in webconfig for time out problem Pin
TweakBird20-Jan-11 0:57
TweakBird20-Jan-11 0:57 
GeneralRe: Increase Execution time for Sp in webconfig for time out problem Pin
Mugdha_Aditya20-Jan-11 1:40
Mugdha_Aditya20-Jan-11 1:40 
AnswerRe: Increase Execution time for Sp in webconfig for time out problem Pin
#realJSOP20-Jan-11 2:25
professional#realJSOP20-Jan-11 2:25 
GeneralRe: Increase Execution time for Sp in webconfig for time out problem Pin
Mugdha_Aditya20-Jan-11 2:52
Mugdha_Aditya20-Jan-11 2:52 
GeneralRe: Increase Execution time for Sp in webconfig for time out problem Pin
Dave Kreskowiak20-Jan-11 4:49
mveDave Kreskowiak20-Jan-11 4:49 
AnswerRe: Increase Execution time for Sp in webconfig for time out problem Pin
Dave Kreskowiak20-Jan-11 4:48
mveDave Kreskowiak20-Jan-11 4:48 
AnswerRe: Increase Execution time for Sp in webconfig for time out problem Pin
Mahendra Vishwakarma23-Jan-11 18:48
Mahendra Vishwakarma23-Jan-11 18:48 
QuestionMake ,windows application contents available and save online Pin
varun.g19-Jan-11 19:45
varun.g19-Jan-11 19:45 
AnswerRe: Make ,windows application contents available and save online Pin
Richard MacCutchan19-Jan-11 21:44
mveRichard MacCutchan19-Jan-11 21:44 
GeneralRe: Make ,windows application contents available and save online Pin
varun.g19-Jan-11 22:04
varun.g19-Jan-11 22:04 
GeneralRe: Make ,windows application contents available and save online Pin
Richard MacCutchan20-Jan-11 1:29
mveRichard MacCutchan20-Jan-11 1:29 
GeneralRe: Make ,windows application contents available and save online Pin
fjdiewornncalwe20-Jan-11 3:39
professionalfjdiewornncalwe20-Jan-11 3:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.