Inputbox

I've seen this tool in Visual Basic and Visual For Pro. But is there an equavilancy of this function is C# .NET Express Straight forward question =]
Thanks in advance


Answer this question

Inputbox

  • Harlan Witherspoon

    Vinces,

    Windows Forms does not have an InputBox control. However, Les Smith wrote one for C#. Check it out at http://www.knowdotnet.com/articles/inputbox.html

    -- Tim Scott
    http://geekswithblogs.net/tscott/


  • paha

    Thanks for the information.

    But I still cannot implement it in VS2005. I am not sure what causes the problem.

    Does anyone tried it on VS2005 Please shared some thoughts with me on the C# InputBox.

    I would like to try not to use Visual Basic component for this propose.

    Thanks in advance.


  • JonHP - MSFT

    Thanks for your help. Sorry if I'm posting too many threads


  • Irenej

    When I use Visual Studio help and search for InputBox filtered by J#, it takes me to a description of the method, which includes both C# and J# definitions:

    J#

    public static String InputBox (
    	String Prompt, 
    	/** @attribute OptionalAttribute() */ String Title, 
    	/** @attribute OptionalAttribute() */ String DefaultResponse, 
    	/** @attribute OptionalAttribute() */ int XPos, 
    	/** @attribute OptionalAttribute() */ int YPos
    )
    It says the namespace is Microsoft.VisualBasic (which I import in my J# Windows form), but the project will not compile, citing InputBox as the 
    reason.
    Is the help lying, or am I missing something 



  • Rani M

    There is no equivalent function in C#.

    However you can refer to VB assembly for getting it . Refer to article

    http://msdn2.microsoft.com/en-us/library/microsoft.visualbasic.interaction.inputbox.aspx

    or you can build one, check out the link

    http://www.knowdotnet.com/articles/inputbox.html


  • Howard Milklin

    hi,

    its very simple creat a form call it inputbox add a textbox and a button to it, select the button and go to properties set "dialogResult" = ok double click the button add to the event handler this.Close(), also add this line to the form code

    public string UserInput

    {

    get { return textBox1.Text; }

    }

    now in your form add this part where you want to get the userinput

    InputBox ib = new InputBox();

    ib.ShowDialog();

    string result = ib.UserInput;

    ib.Dispose();

    hope this helps


  • Inputbox