C#-TextBox-登录窗口密码不可见---ShinePans

来源:互联网 发布:查海关数据 编辑:程序博客网 时间:2024/05/28 06:08
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;    }}


7 1
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 如果小学生长胸只长了一个该怎么办 脸上毛多导致的毛孔粗怎么办 吃了激素药头发掉的厉害怎么办 剪发的剪子中间的螺丝扣总掉怎么办 染完头发后一段时间长新头发怎么办 睡觉头发老被老公压着怎么办 漆盖关节不自在怎么办?吃什么好 摆床头的位置后面是弧形位怎么办 君子兰的根全烂掉了只剩茎怎么办 老板不发工资怎么办 没签合同的 牙套粘在牙齿上的松了怎么办 缝的线长在肉里怎么办 小孩喜欢用舌头顶牙齿缝怎么办 1岁多小宝贝全身长红点怎么办 生完胸好涨但很难把奶吸出来怎么办 怀孕快9个月内裤上有白带怎么办 一早起来发现内裤有白色液体怎么办 阴部骚痒白带多白带多小腹痛怎么办 15岁一周鲁了3次怎么办 月经摊迟三天内裤有白带怎么办 怀孕内裤上有黄黄的分泌物怎么办 老公出轨想离婚但舍不得孩子怎么办 老婆出轨离婚又舍不得家我该怎么办 怀孕一个月刚刚自慰有点流血怎么办 老公出轨还不知道悔改妻子怎么办 离婚了前妻户口还在再婚怎么办 怀孕六个月内裤老是湿有异味怎么办 怀孕五个月内裤总是湿有异味怎么办 耳朵里面有个洞老是流水冒浓怎么办 宝宝拉粑粑有臭酸味怎么回事怎么办 老婆晚上回家内裤是湿的尿味怎么办 怀孕五个月下身痒内裤湿怎么办 哺乳期奶水太多经常弄湿衣服怎么办 麻料裙子一坐下就皱怎么办 不小心把答题卡弄皱了怎么办 嘴巴又干又黏又臭怎么办 不小心把红枣核吞了怎么办 小天才电话手表被偷了怎么办 18k金被火烧黑了怎么办 衣服掉色染到别的衣服上怎么办 夏天太阳太毒刚发芽的花种子怎么办