In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "how to input a password in a pop-up window in C#". The editor shows you the operation process through an actual case. The operation method is simple and fast, and it is practical. I hope this article "how to realize the pop-up window prompt to input password" article can help you solve the problem.
The details are as follows
String PM = Interaction.InputBox ("Please enter the password", "enter the password", "100,100); if (PM! =" 2222 ") {MessageBox.Show (" Please enter the correct password thank you! ") ; return;}
If the password you need to enter is encrypted *, you need to customize the control and call this class directly to InputBox.
The method of use is:
String inMsg = InputBox.ShowInputBox ("Please enter the password of the administrator (admin), string.Empty); if (inMsg.Trim ()! = string.Empty) {MessageBox.Show (inMsg);}
InputBox class
Using System;using System.Collections.Generic;using System.Text;using System.Windows.Forms; public class InputBox: System.Windows.Forms.Form {private TextBox textBox_Data; private Button button_Enter; private Button button_Esc; private System.ComponentModel.Container components = null; private InputBox () {InitializeComponent (); this.TopMost = true; / / this.StartPosition = FormStartPosition.CenterScreen; / / inputbox.Location.X = 0 Inputbox.Location.Y = 0; / / inputbox.StartPosition = FormStartPosition.CenterScreen; / / inputbox.Left = 0; / / inputbox.Top = 0;} protected override void Dispose (bool disposing) {if (disposing) {if (components! = null) {components.Dispose ();}} base.Dispose (disposing) } private void InitializeComponent () {this.textBox_Data = new System.Windows.Forms.TextBox (); this.button_Enter = new System.Windows.Forms.Button (); this.button_Esc = new System.Windows.Forms.Button (); this.SuspendLayout (); / textBox_Data / / this.textBox_Data.Location = new System.Drawing.Point (8,8) This.textBox_Data.Name = "textBox_Data"; this.textBox_Data.PasswordChar ='*'; this.textBox_Data.Size = new System.Drawing.Size (230,21); this.textBox_Data.TabIndex = 2; this.textBox_Data.KeyDown + = new System.Windows.Forms.KeyEventHandler (this.textBox_Data_KeyDown) / button_Enter / / this.button_Enter.Location = new System.Drawing.Point (25,43); this.button_Enter.Name = "button_Enter"; this.button_Enter.Size = new System.Drawing.Size (75,23); this.button_Enter.TabIndex = 3; this.button_Enter.Text = "confirmation" This.button_Enter.UseVisualStyleBackColor = true; this.button_Enter.Click + = new System.EventHandler (this.button_Enter_Click); / button_Esc / / this.button_Esc.Location = new System.Drawing.Point (140,43); this.button_Esc.Name = "button_Esc"; this.button_Esc.Size = new System.Drawing.Size (75,23) This.button_Esc.TabIndex = 4; this.button_Esc.Text = "cancel"; this.button_Esc.UseVisualStyleBackColor = true; this.button_Esc.Click + = new System.EventHandler (this.button_Esc_Click); / InputBox / / this.AutoScaleBaseSize = new System.Drawing.Size (6,14); this.ClientSize = new System.Drawing.Size (250,80) This.Controls.Add (this.button_Esc); this.Controls.Add (this.button_Enter); this.Controls.Add (this.textBox_Data); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; this.ControlBox = false; this.Name = "InputBox"; this.Text = "InputBox" This.ResumeLayout (false); this.PerformLayout ();} / / A pair of keyboards respond to private void textBox_Data_KeyDown (object sender, KeyEventArgs e) {if (e.KeyCode = = Keys.Enter) {button_Enter_Click (sender, e);} else if (e.KeyCode = = Keys.Escape) {button_Esc_Click (sender, e) }} private void button_Enter_Click (object sender, EventArgs e) {this.Close ();} private void button_Esc_Click (object sender, EventArgs e) {textBox_Data.Text = string.Empty; this.Close ();} / / display InputBox public static string ShowInputBox (int Left, int Top, string Title, string Prompt, string DefaultResponse) {InputBox inputbox = new InputBox () If (Title.Trim ()! = string.Empty) inputbox.Text = Title; if (DefaultResponse.Trim ()! = string.Empty) inputbox.textBox_Data.Text = DefaultResponse; inputbox.ShowDialog () inputbox.Left = Left; inputbox.Top = Top; return inputbox.textBox_Data.Text;} public static string ShowInputBox (FormStartPosition Position, string Title, string Prompt, string DefaultResponse) {InputBox inputbox = new InputBox () Inputbox.StartPosition = Position; if (Title.Trim ()! = string.Empty) inputbox.Text = Title; if (DefaultResponse.Trim ()! = string.Empty) inputbox.textBox_Data.Text = DefaultResponse; inputbox.ShowDialog (); return inputbox.textBox_Data.Text;} public static string ShowInputBox () {return ShowInputBox (FormStartPosition.CenterScreen, string.Empty, string.Empty, string.Empty) } public static string ShowInputBox (string Title) {return ShowInputBox (FormStartPosition.CenterScreen, Title, string.Empty, string.Empty);} public static string ShowInputBox (string Title, string Prompt) {return ShowInputBox (FormStartPosition.CenterScreen, Title, Prompt, string.Empty);} public static string ShowInputBox (string Title, string Prompt, string DefaultResponse) {return ShowInputBox (FormStartPosition.CenterScreen, Title, Prompt, DefaultResponse) } / / call / / string inMsg = InputBox.ShowInputBox ("Please enter the password of the administrator (admin), string.Empty); / / if (inMsg.Trim ()! = string.Empty) / / {/ / MessageBox.Show (inMsg) / /}} about "how to realize the pop-up window prompt for password", this is the end of the introduction. Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.