C#-TextBox-登录窗口密码不可见—ShinePans[通俗易懂]

C#-TextBox-登录窗口密码不可见—ShinePans[通俗易懂]usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;namespaceTextB

大家好,又见面了,我是你们的朋友全栈君。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TextBox_1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            textBox1.PasswordChar = '@'; //设置文本框的PasswordChar属性为字符@
            textBox2.UseSystemPasswordChar = true;
            //设置文本框的UseSystemPasswordChar属性为True;
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
    }
}

program.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace TextBox_1
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            //Enabled 获取或设置一个值,该值指示控件是否可以对用户交互做出响应
            //ForeColor:获取或设置控件的前景色
            //Modifiers:指示TextBox控件的可见性级别
            //Multiline://获取或设置字符,该字符用于
            //PasswordChar:获取或设置字符
            //                          :public char PasswordChar{get; set;}
            //ReadOnly:获取或设置一个值,该值指示文本框中的文本是否为只读
            //               :public bool ReadOnly{get ; set; }
            //               :TextBox.ReadOnly=true;  将文本设置为只读
            //RightToLeft:获取或设置一个值.该值指示是否将控件的元素对齐以支持使用从右向左的字体区域设置
            //ScrollBars:获取或设置哪些滚动条应出现在多行TextBox控件中
            //Text:获取或设置TextBox控件的文本
            //UseSystemPasswordChar:获取或设置一个值,该值指示TextBox控件中的文本是否应该以默认的密码字符显示
            //                                              :public Bool UseSystemPasswordChar{get ;set ;}
            //Visible:获取或设置一个值,该值指示是否显示该控件及其所有父控件
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());

        }
    }
}

Form设计:

namespace TextBox_1
{
    partial class Form1
    {
        /// <summary>
        /// 必需的设计器变量。
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// 清理所有正在使用的资源。
        /// </summary>
        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows 窗体设计器生成的代码

        /// <summary>
        /// 设计器支持所需的方法 - 不要
        /// 使用代码编辑器修改此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.textBox2 = new System.Windows.Forms.TextBox();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.SuspendLayout();
            // 
            // textBox1
            // 
            this.textBox1.Location = new System.Drawing.Point(155, 27);
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new System.Drawing.Size(121, 21);
            this.textBox1.TabIndex = 0;
            // 
            // textBox2
            // 
            this.textBox2.Location = new System.Drawing.Point(155, 77);
            this.textBox2.Name = "textBox2";
            this.textBox2.Size = new System.Drawing.Size(121, 21);
            this.textBox2.TabIndex = 1;
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(66, 30);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(83, 12);
            this.label1.TabIndex = 2;
            this.label1.Text = "PassWordChar:";
            this.label1.Click += new System.EventHandler(this.label1_Click);
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(12, 80);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(137, 12);
            this.label2.TabIndex = 3;
            this.label2.Text = "UseSystemPassWordChar:";
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(318, 151);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.textBox2);
            this.Controls.Add(this.textBox1);
            this.Name = "Form1";
            this.Text = "登录";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.TextBox textBox1;
        private System.Windows.Forms.TextBox textBox2;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
    }
}


C#-TextBox-登录窗口密码不可见---ShinePans[通俗易懂]

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/161502.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 项目管理第五章项目范围管理内容_项目范围管理在规划过程组四个模块

    项目管理第五章项目范围管理内容_项目范围管理在规划过程组四个模块项目管理第五章项目范围管理项目范围管理:范围管理确保项目做且只做所需的工作,项目范围管理过程包括:规划范围管理:为记录如何定义、确认和控制项目范围及产品范围,而创建范围管理计划的过程。收集需求:为实现项目目标而确定、记录并管理相关方的需要和需求的过程。定义范围:制定项目和产品详细描述的过程。创建WBS:将可交付成果和工作分解为较小、易于管理的组建过程。确认范围:正式验收已完成的项目可交付成果的过程。控制范围:监督项目和产品的范围状态管理范围基准变更的过程。范围管理的核心理念:

    2022年9月22日
    2
  • mac pycharm永久激活_mac apfs 格式

    mac pycharm永久激活_mac apfs 格式问题Pycharm使用秘钥登录服务器需要RAS格式的秘钥,然而我们在MAC上直接用ssh-keygen生成的秘钥并不满足格式要求,会发生如下报错。***iscorruptorhasunknownformat.OnlySSH2keysinOpenSSHformat(DSA,RSA,ECDSA)orPuTTYPrivateKey*.ppkkeysaresupported.Errormessage:invalidprivatekey:[B@5233fcc0

    2022年8月28日
    1
  • stringtokenizer是什么意思_string getbytes

    stringtokenizer是什么意思_string getbytesStringTokenizer是一个用来分隔String的应用类。构造函数publicStringTokenizer(Stringstr)publicStringTokenizer(Stringstr,Stringdelim)publicStringTokenizer(Stringstr,Stringdelim,booleanreturnDelims)第一个参

    2022年8月11日
    6
  • Hadoop生态系统简介

    Hadoop生态系统简介Hadoop生态系统主要包括:Hive、HBase、Pig、Sqoop、Flume、ZooKeeper、Mahout、Spark、Storm、Shark、Phoenix、Tez、Ambari。Hive:用于Hadoop的一个数据仓库系统,它提供了类似于SQL的查询语言,通过使用该语言可以方便地进行数据汇总,特定查询以及分析存放在Hadoop兼容文件系统中的大数据。HBase:一种分布的、可

    2022年5月19日
    39
  • 【JavaScript框架封装】实现一个类似于JQuery的属性框架的封装

    【JavaScript框架封装】实现一个类似于JQuery的属性框架的封装

    2021年6月9日
    104
  • 【转载】ORM的概念, ORM到底是什么

    【转载】ORM的概念, ORM到底是什么

    2021年11月21日
    44

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号