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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • linux0.11_linux vim安装

    linux0.11_linux vim安装前言所有的UnixLike系统都会内建vi文书编辑器,其他的文书编辑器则不一定会存在。但是目前我们使用比较多的是vim编辑器。vim具有程序编辑的能力,可以主动的以字体颜色辨别语法的

    2022年7月29日
    5
  • BeanUtils.copyProperties 用法

    BeanUtils.copyProperties 用法BeanUtils.copyProperties方法不用操作过多的set/get方法,两个类字段相同的时候我们可以通过此方法来进行复制,如有不想复制的属性则用第三个构造参数来进行,如果你只需要改其中的一个属性或者两个属性没必要重新get/set一边直接复制原来的类,付给新类属性名相同即可赋值。…

    2022年9月1日
    5
  • pycharm设置断点单步运行_pycharm怎么debug

    pycharm设置断点单步运行_pycharm怎么debug在我们平时写程序的时候,简单的程序一眼就能看出问题所在,但是稍微大一点的程序,就很难在茫茫代码中找到一个参数的失误带来的bug,所以我们引入debug单步调试。一、常用操作F8:stepover单步遇到断点后,程序停止运行,按F8单步运行。不进入调用函数内部F7:stepinto进入配合F8使用。单步调试F8时,如果某行调用其他模块的函数,在此执行F7,可以进入函数内部,如果是F…

    2022年8月27日
    39
  • 程序猿的量化交易之路(26)–Cointrader之Listing挂牌实体(13)

    程序猿的量化交易之路(26)–Cointrader之Listing挂牌实体(13)

    2022年1月23日
    44
  • 大数据开发基础之Java基础[通俗易懂]

    大数据开发基础之Java基础[通俗易懂]大数据给很多人的感觉是,专业性强,操作繁琐,属于“高大上”的技术。大数据人才供不应求,有一些人则看到了大数据带来的机遇,想通过专业的培训来学习大数据,那么大数据从0开始需要学习些什么内容呢一、0基础学习大数据需要Java基础Java:开发需求最多的编程语言之一,可以从事网站开发、桌面程序设计、游戏开发、安卓后台开发、全栈开发等。它可以说是大数据最基础的编程语言,一是大数据的本质是…

    2022年5月22日
    44
  • UML图:活动图详细介绍

    UML图:活动图详细介绍活动图简介什么是活动图(ActivityDiagram)活动图是UML用于对系统的动态行为建模的另一种常用工具,它描述活动的顺序,展现从一个活动到另一个活动的控制流,活动图在本质上是一种流程图;活动图着重表现从一个活动到另一个活动的控制流活动图元素动作状态(ActionState)动作状态是指原子的,不可中断的动作,并在此动作完成后通过完成转换转向另一个状态在UML中的动作状态图用平滑的圆角矩形表示动作状态的特点动作状态是原子的,无法分解为更小的部分动作状态是不可中断的,一旦开始

    2022年5月1日
    51

发表回复

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

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