最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C#實(shí)現(xiàn)彈窗提示輸入密碼

 更新時(shí)間:2022年02月12日 11:27:18   作者:馬兒不吃草  
這篇文章主要為大家詳細(xì)介紹了C#實(shí)現(xiàn)彈窗提示輸入密碼,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了C#實(shí)現(xiàn)彈窗提示輸入密碼的具體代碼,供大家參考,具體內(nèi)容如下

String PM = Interaction.InputBox("請(qǐng)輸入密碼", "輸入密碼", "", 100, 100);
if (PM != "2222")
{
? ? MessageBox.Show("請(qǐng)輸入正確的密碼謝謝!?。。?!");
? ? return;
}

如果需要輸入的密碼為加密****,則需要自定義控件,直接調(diào)用該類即可InputBox

使用方法為:

string inMsg = InputBox.ShowInputBox("請(qǐng)輸入管理員(admin)的密碼", string.Empty);
if (inMsg.Trim() != string.Empty)
{
? ? MessageBox.Show(inMsg);
}

InputBox類

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 = "確 認(rèn)";
? ? ? ? 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 = "取 消";
? ? ? ? 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();
?
? ? }
?
? ? //對(duì)鍵盤進(jìn)行響應(yīng)
? ? 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();
? ? }
?
?
? ? //顯示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);
? ? }
// 調(diào)用
// ? ? ? ? ? string inMsg = InputBox.ShowInputBox("請(qǐng)輸入管理員(admin)的密碼", string.Empty);
// ? ? ? ? ? ?if (inMsg.Trim() != string.Empty)
// ? ? ? ? ? ? {
// ? ? ? ? ? ? ? ? MessageBox.Show(inMsg);
// ? ? ? ? ? ? }
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

您可能感興趣的文章:

相關(guān)文章

  • C# XML序列化方法及常用特性總結(jié)分析

    C# XML序列化方法及常用特性總結(jié)分析

    這篇文章主要介紹了C# XML序列化方法及常用特性,總結(jié)分析了C# xml序列化的實(shí)現(xiàn)方法及序列化常用Attribute含義與功能,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2016-06-06
  • C#日期格式字符串的相互轉(zhuǎn)換操作實(shí)例分析

    C#日期格式字符串的相互轉(zhuǎn)換操作實(shí)例分析

    這篇文章主要介紹了C#日期格式字符串的相互轉(zhuǎn)換操作,結(jié)合實(shí)例形式分析了C#日期格式字符串的相互轉(zhuǎn)換操作函數(shù)與相關(guān)使用技巧,需要的朋友可以參考下
    2019-08-08
  • 淺析C#中結(jié)構(gòu)與類的區(qū)別

    淺析C#中結(jié)構(gòu)與類的區(qū)別

    本文主要對(duì)C#結(jié)構(gòu)與類的區(qū)別進(jìn)行簡(jiǎn)要分析,文中舉了實(shí)例,便于理解,具有很好的參考價(jià)值,需要的朋友一起來(lái)看下吧
    2016-12-12
  • C#導(dǎo)出Excel的方法

    C#導(dǎo)出Excel的方法

    本文給大家分享的是基于.net 1.0開發(fā)的程序如何實(shí)現(xiàn)導(dǎo)出Excel的方法和示例,使用的是UltraWebGrid自帶導(dǎo)出Excel的控件,非常的簡(jiǎn)單實(shí)用,有需要的小伙伴可以參考下。
    2015-06-06
  • C#編寫DES加密、解密類

    C#編寫DES加密、解密類

    本文給大家匯總了一下使用C#實(shí)現(xiàn)的DES加密、解密類的代碼,十分的簡(jiǎn)單實(shí)用,有需要的小伙伴可以參考下
    2015-05-05
  • C#5.0中的異步編程關(guān)鍵字async和await

    C#5.0中的異步編程關(guān)鍵字async和await

    這篇文章介紹了C#5.0中的異步編程關(guān)鍵字async和await,文中通過(guò)示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-06-06
  • 基于C#后臺(tái)調(diào)用跨域MVC服務(wù)及帶Cookie驗(yàn)證的實(shí)現(xiàn)

    基于C#后臺(tái)調(diào)用跨域MVC服務(wù)及帶Cookie驗(yàn)證的實(shí)現(xiàn)

    本篇文章介紹了,基于C#后臺(tái)調(diào)用跨域MVC服務(wù)及帶Cookie驗(yàn)證的實(shí)現(xiàn)。需要的朋友參考下
    2013-04-04
  • C# 延遲Task.Delay()和Thread.Sleep()的具體使用

    C# 延遲Task.Delay()和Thread.Sleep()的具體使用

    Thread.Sleep()是同步延遲,Task.Delay()是異步延遲,本文主要介紹了C# 延遲Task.Delay()和Thread.Sleep()的具體使用,文中通過(guò)示例代碼介紹的非常詳細(xì),需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2024-01-01
  • C# IDE VS2005中的Hosting Process (vshost.exe)作用介紹

    C# IDE VS2005中的Hosting Process (vshost.exe)作用介紹

    這篇文章主要介紹了C# IDE VS2005中的Hosting Process (vshost.exe)作用介紹,vshost.exe是一個(gè)宿主進(jìn)程,主要用來(lái)提高調(diào)試效率,需要的朋友可以參考下
    2015-01-01
  • WPF通過(guò)使用C#代碼給控件賦值

    WPF通過(guò)使用C#代碼給控件賦值

    開發(fā)中偶爾會(huì)用到使用c#代碼給控件賦值,這里需要通過(guò)F12找到控件的賦值類型,然后在看控件可以使用那種方式賦值,花點(diǎn)時(shí)間研究一下,基本都可以通過(guò)c#代碼給控件賦值的,需要的朋友可以參考下
    2023-09-09

最新評(píng)論

岫岩| 库尔勒市| 洪湖市| 祁连县| 夹江县| 墨江| 安徽省| 修水县| 商南县| 兰溪市| 泽普县| 奉贤区| 唐河县| 越西县| 米泉市| 钟祥市| 靖江市| 泰宁县| 石泉县| 景东| 正镶白旗| 南阳市| 自贡市| 柳州市| 揭东县| 海南省| 防城港市| 石屏县| 宝鸡市| 冕宁县| 聂拉木县| 双鸭山市| 锡林郭勒盟| 色达县| 竹溪县| 庐江县| 汶上县| 原阳县| 双辽市| 旬阳县| 曲阜市|