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


相关推荐

  • tcp为什么是三次握手不是两次握手_tcp四次挥手

    tcp为什么是三次握手不是两次握手_tcp四次挥手一、为什么握手是三次,而不是两次或者四次?答:两次不安全,四次没必要。tcp通信需要确保双方都具有数据收发的能力,因此双方都要发送SYN确保对方具有通信的能力二、为什么挥手是四次而不是三次?答:发送FIN包只能表示对方不再发送数据了,不代表对方不再接收数据,因此被动关闭方进行ACK回复之后有可能还会继续发送数据,等到不再发送数据了才会发送下一个FIN包,因此FIN包和ACK包是分开的…

    2022年10月3日
    5
  • intellij 激活码_通用破解码

    intellij 激活码_通用破解码,https://javaforall.net/100143.html。详细ieda激活码不妨到全栈程序员必看教程网一起来了解一下吧!

    2022年3月16日
    85
  • 软件测试笔记总结(探灵笔记手机版下载教程)

    软件测试复习(部分)概述程序+文档+数据=软件狭义的软件测试定义:为发现软件缺陷而执行程序或系统的过程广义的软件测试定义:人工或自动地运行或测定某系统的过程,目的在于检验它是否满足规定的需求或弄清预期结果和实际结果间的差别为什么要做软件测试发现软件缺陷功能错功能遗漏超出需求部分(画蛇添足)性能不符合要求软件质量高低:是否符合用户习惯、符合用户需求测试…

    2022年4月15日
    102
  • workbench mesh搅拌釜网格划分

    workbench mesh搅拌釜网格划分首先在scdm中创建几何模型导入workbenchmesh中进行划分,导出为msh格式网格即可单击mesh,调整参数,比如修改physics为CFD等 选中geometry第二个body,右击选择suppressbody,此时只剩下一个body 右击mesh,选择insertmethod,选择几何,选择默认参数 单击generatemesh,生成网格 单击第…

    2022年5月25日
    79
  • Epel镜像_镜像包

    Epel镜像_镜像包简介EPEL(ExtraPackagesforEnterpriseLinux),是由FedoraSpecialInterestGroup维护的EnterpriseLinux(RHEL、CentOS)中经常用到的包。一.安装清华大学开源软件镜像站的epel镜像,即yum源yuminstallepel-release二.安装阿里的epel镜像,即yum源1.备份(如有配置其他epel源)mv/etc/yum.repos.d/epel.rep..

    2025年7月2日
    4
  • fastjson把map转json_fastjson转list对象

    fastjson把map转json_fastjson转list对象Stringtest=”jdkalkjda|||djkdla|||djlak”;Stringstr[]=test.split(“\\|\\|\\|”);System.out.println(str.length);HashMapt=newHashMap();HashMapt1=newHashMap();t1.put(“k”,”3″);Objects1=JSONObj…

    2022年10月4日
    4

发表回复

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

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