Reputation: 5522
I'm very new to creating windows mobile applications. I have a button called 'Settings'- i want this to open a small popup that overlaps the current window with purely a textbox asking for a password. How would I go about this? Do I have to create a new form, but size the form accoringly?
I've created a new form and sized it much smaller, but when it opens, it is full screen.
Any help appreaciated
Upvotes: 2
Views: 1851
Reputation:
For the Pop-Up dialog effect, drop a Panel
control onto your main form that you call "loginPnl" or something like with one or more TextBox
controls and some Button
controls for "OK" and "Cancel". Set Visible to False and stick it behind your other controls.
private Panel loginPnl;
public Form1() {
InitializeComponent();
loginPnl.SendToBack();
loginPnl.Visible = false;
}
Now, whenever you are ready for someone to log in, just call your custom Login routine:
private void LoginPanel(bool show) {
// don't forget to reset your TextBox controls
loginPnl.Visible = show;
if (loginPnl.Visible) {
loginPnl.BringToFront();
txtLoginPwd1.Text = null;
txtLoginPwdVerify.Text = null;
} else {
loginPnl.SendToBack();
}
}
Don't forget to hide your Login Panel afterwards, though.
Upvotes: 3
Reputation: 6452
Try creating a form that encapsulates your login functionality, then form.ShowDialog(). This will provide more than just a textbox, though, as it will also provide buttons to dismiss the dialog (which I would recommend versus ONLY having a textbox).
If you really want to have only the textbox then you'll need to "fade" all other areas of the screen to give the impression those controls/areas are temporarily nonusuable while your textbox is shown (and other related aspects like focus traversal).
Upvotes: 0