Miguel Marzo
Miguel Marzo

Reputation: 75

C# Interaction.inputbox 2 inputs

I have a simple form with a button that opens an "admin form", and now I need to prompt an input box or something similar asking for "user" and "password" in order to actually access this "admin form".

I have this code:

private void btnAdmin_Click(object sender, EventArgs e)
{
    Interaction.InputBox("Admin Log-In", "Administración", "Default Text");

    //frmAdmin admin = new frmAdmin();
    //admin.Show();
}

And this Interaction.InputBox works perfectly, it can get me 1 input field, but I need another one for the password.

Anyone knows how to make an InputBox with 2 inputs? I have considered just using 2 inputboxes one after the other, but I`d rather use only one if its possible!

Thanks!

Upvotes: 2

Views: 4081

Answers (1)

SergGr
SergGr

Reputation: 23788

Microsoft can't provide you with pre-made dialogs for all cases. At some point you have to roll up your sleeves and create a custom form and show it modally using Form.ShowDialog. This also allows you many customizations such as showing one input box as a plain text and another as password, do some basic verifications (both fields are non empty) etc. Overview at https://msdn.microsoft.com/en-us/library/2chz8edb(v=vs.110).aspx might help you do that, particularly Walkthrough: Retrieving Dialog Box Information Collectively Using Objects

Upvotes: 4

Related Questions