登录
首页 » C#源码 » C# 将textBox文本框设置为只读

C# 将textBox文本框设置为只读

于 2023-06-29 发布 文件大小:33.45 kB
0 283
下载积分: 2 下载次数: 1

代码说明:

C# 将文本框设置为只读,设置只读后,textBox只能使用复制功能,粘贴或编辑都为灰色不可用,本功能的实现方法挺简单,使用文本框的ReadOnly即可,具体用法如下:   textBox1.ReadOnly = true;//将文本框设置为只读   textBox1.Text = "源码素材网";//设置其Text属性

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • C#演示如何正确关闭程序
    C#演示如何正确关闭程序,这是一个Wpf窗体实例,演示WPF窗口如何才是正确的关闭方法。   其实下边这句话最重要:   正确关闭程序的方法:App.Current.Shutdown();   具体的代码写法如下:   //文件名称:Window1.xaml.cs   private void button1_Click(object sender, RoutedEventArgs e)   {//正确关闭程序    App.Current.Shutdown();   }
    2023-04-28 12:25:02下载
    积分:1
  • C# wpf 获取并显示掩码文本框中的数据
    C# wpf 获取并显示掩码文本框中的数据,也就是显示密码框中的字符,private void MaskedTextBox_TextChanged(object sender, EventArgs e)   {//获取掩码文本框中的数据    var MyBox = sender as System.Windows.Forms.MaskedTextBox;    MyText = MyBox.Text;   }   private void Button_Click(object sender, EventArgs e)   {//显示在掩码文本框中输入的数据    MessageBox.Show("刚才在掩码文本框中输入的数据是:" + MyText, "信息提示");   }
    2023-03-13 11:25:03下载
    积分:1
  • C# WPF 不使用演示图板的文字滚动动画
    C#实现按钮中的文字滚动,此为一个 不使用演示图板的文字滚动动画的制作例子,运行后,文字框由小变大,文字左右方向来回滚动,一个比较简单基础的C#文字循环滚动的例子,对学习熟悉WPF的相关属性操作很有帮助。
    2022-03-21 01:36:45下载
    积分:1
  • C# 最简单的文件复制实例
    C# 最简单的文件复制实例,文件拷贝的示例,比较简单,若要启用启用xp_cmdshell, 请查看启用xp_cmdshell使用说明。
    2022-03-01 11:06:17下载
    积分:1
  • C# 使用Graphics对象的DrawRectangle方法绘制粗边框图形
    C# 使用Graphics对象的DrawRectangle方法绘制粗边框图形,可以方便的自定义图形的边框大小,如示例截图所示的效果,具体的代码编写方法为:   private void button1_Click(object sender, EventArgs e)   {    Graphics graphics = this.CreateGraphics();//声明一个Graphics对象    Pen myPen = new Pen(Color.Black, 8);//实例化Pen类    //调用Graphics对象的DrawRectangle方法    graphics.DrawRectangle(myPen, 10, 10, 150, 100);   }
    2022-03-24 16:40:35下载
    积分:1
  • c# 关闭窗口前确认 弹出提示
    与大家分享一个C#窗口编程小技巧,在用户关闭窗口前,弹出确认对话框,可有效防止用户误操作,误关闭窗口。本源码中是完整的实例下载 ,有基础的可参考以下的代码,快速实现本功能:   C#弹出关闭窗口的确认对话框,核心代码如下:   private void Form1_FormClosing(object sender, FormClosingEventArgs e)   {    DialogResult dr = MessageBox.Show("是否关闭窗体", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);    if (dr == DialogResult.Yes) //使用if语句判断是否单击“是”按钮    {    e.Cancel = false;//如果单击“是”按钮则关闭窗体    }    else//否则    {    e.Cancel = true;//不执行操作    }   }   当用户单击窗口右上角关闭按钮时,激活函数中的命令,弹出确认框。
    2022-01-25 15:52:19下载
    积分:1
  • 7Zip
    This file is part of SevenZipSharp.    SevenZipSharp is free software: you can redistribute it and/or modify    it under the terms of the GNU Lesser General Public License as published by    the Free Software Foundation, either version 3 of the License, or    (at your option) any later version.    SevenZipSharp is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    GNU Lesser General Public License for more details.    You should have received a copy of the GNU Lesser General Public License    along with SevenZipSharp.  If not, see .
    2022-07-20 00:09:31下载
    积分:1
  • C# 在密钥容器中创建非对称密钥
    在密钥容器中创建非对称密钥、在密钥容器中删除非对称密钥、在密钥容器中获取非对称密钥,具体的实现代码,请参考如下代码:   private void button1_Click(object sender, EventArgs e)   {//在密钥容器中创建非对称密钥    CspParameters MyCSP = new CspParameters();    MyCSP.KeyContainerName = this.textBox2.Text;    RSACryptoServiceProvider MyRSA = new RSACryptoServiceProvider(MyCSP);    this.textBox1.Text=MyRSA.ToXmlString(true);   }   private void button2_Click(object sender, EventArgs e)   {//在密钥容器中删除非对称密钥    CspParameters MyCSP = new CspParameters();    MyCSP.KeyContainerName = this.textBox2.Text;    RSACryptoServiceProvider MyRSA = new RSACryptoServiceProvider(MyCSP);    MyRSA.PersistKeyInCsp = false;    MyRSA.Clear();    try    {    this.textBox1.Text = MyRSA.ToXmlString(true);    }    catch    {    this.textBox1.Text = "已经删除非对称密钥!";    }   }   private void button3_Click(object sender, EventArgs e)   {//在密钥容器中获取非对称密钥    CspParameters MyCSP = new CspParameters();    MyCSP.KeyContainerName = this.textB
    2022-02-06 13:18:17下载
    积分:1
  • C#使用SqlDataAdapter对象的Fill方法填充DataSet
    C#使用SqlDataAdapter对象的Fill方法填充DataSet,具体是调用DataSet的Copy方法复制DataSet中的内容,完成填充的功能:   private void Form1_Load(object sender, EventArgs e)   {    //实例化SqlConnection变量conn,连接数据库    conn = new SqlConnection("server=.;database=db_14;uid=sa;pwd=");    //创建一个SqlCommand对象    SqlCommand cmd = new SqlCommand("select * from tb_test", conn);    SqlDataAdapter sda = new SqlDataAdapter();//创建一个SqlDataAdapter对象    //设置SqlDataAdapter对象的SelectCommand属性,设置执行的SQL语句    sda.SelectCommand = cmd;    ds = new DataSet(); //实例化DataSet    sda.Fill(ds, "test");//使用SqlDataAdapter对象的Fill方法填充DataSet    dataGridView1.DataSource = ds.Tables[0];//设置dataGridView1的数据源   }   private void button1_Click(object sender, EventArgs e)   {    DataSet ds1 = ds.Copy();//调用DataSet的Copy方法复制ds中的内容    dataGridView2.DataSource = ds1.Tables[0];//将ds1作为dataGridView2的数据源   }
    2022-11-04 09:50:03下载
    积分:1
  • C#演示用Brush填充Rectangle图形
    C#画矩形,然后使用Brush填充Rectangle图形,单击按钮后会生成一个填充过的图形,需要创建Graphics对象,创建一个Brush对象,再使用Rectangle绘制一个矩形,然后使用Brush填充,实现这一过程,核心代码如下:   private void button1_Click(object sender, EventArgs e)   {    Graphics ghs = this.CreateGraphics();//创建Graphics对象    Brush mybs = new SolidBrush(Color.Red);//使用SolidBrush类创建一个Brush对象    Rectangle rt = new Rectangle(10, 10, 100, 100);//绘制一个矩形    ghs.FillRectangle(mybs, rt);//用Brush填充Rectangle   }
    2022-07-06 17:10:54下载
    积分:1
  • 696516资源总数
  • 106914会员总数
  • 0今日下载