登录
首页 » C#源码 » C# 输入界面中的各种文本框判断效果演示

C# 输入界面中的各种文本框判断效果演示

于 2022-01-25 发布 文件大小:60.53 kB
0 155
下载积分: 2 下载次数: 1

代码说明:

这是一个实用的输入判断验证演示程序,面向C#编程环境,当用户输入的数据不正确或为空时,均会显示提示,不过这个提示是一个图标在闪烁,直到输入正确,下面是判断机制:   private void textBox2_Validating(object sender, System.ComponentModel.CancelEventArgs e)   {    if (textBox2.Text == "")//判断是否输入订货数量    {    errorProvider2.SetError(textBox2, "不能为空");//设置errorProvider2的错误提示    }    else    {    try    {    int x = Int32.Parse(textBox2.Text);//判断是否输入数字,如果不是数字会出现异常    errorProvider2.SetError(textBox2, "");// errorProvider2控件不显示任何错误信息    b = 1;//将b赋值为1    }    catch    {    //如果出现异常,设置errorProvider2控件的错误信息    errorProvider2.SetError(textBox2, "请输入一个数");    }    }   }   private void textBox3_Validating(object sender, System.ComponentModel.CancelEventArgs e)   {    if (textBox3.Text == "")//判断是否输入订货数量    {    errorProvider3.SetError(textBox3, "不能为空");//设置errorProvider3显示的错误消息    }    else    {    errorProvider3.SetError(textBox

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

发表评论

0 个回复

  • C# 设置DataGridView控件中的指定(第二)列只读
    C# 设置DataGridView控件中的指定(第二)列只读,核心代码如下:   private void Form1_Load(object sender, EventArgs e)   {    this.customersTableAdapter.Fill(this.northwindDataSet.Customers);    //设置DataGridView控件中的指定(第二)列只读    this.customersDataGridView.Columns[1].ReadOnly = true;   }
    2022-02-12 23:56:36下载
    积分:1
  • Visual C# 定制个性化的winForm窗体
    Visual C# 定制个性化的winForm窗体,自定义窗体的按钮和标题栏,最终运行效果如示例截图所示,看一看窗体的标题 栏完全和默认的风格不一样了,更接近于Windows8的扁平化风格了,呵呵,或许只是我的个人感觉。右侧是一个大按钮,总之这个窗口中的元素都是自定义的,不是默认的,对于以后自定义个性化的窗口分享一些技巧。
    2022-04-10 03:00:12下载
    积分:1
  • 二维生成的C(QRCODE)
    二维码(QRCODE)生成的C源代码,比较完整,测试可用
    2022-01-30 22:00:53下载
    积分:1
  • 传世
    传世源码传世源码传世源码传世源码传世源码传世源码传世源码
    2022-03-03 05:08:19下载
    积分:1
  • C#结合数据库生成饼形图表
    C#结合数据库生成饼形图表,这种图表是常见的数据统计图表,饼形图、柱状图等使用十分广泛,本程序演示了C#从数据库中读取出数据,然后交给饼形图生成模块,加载数据生成饼形图表。   //清空背景色   g.Clear(Color.White);   Pen pen1 = new Pen(Color.Red);   Brush brush1 = new SolidBrush(Color.PowderBlue);   Brush brush2 = new SolidBrush(Color.Blue);   Brush brush3 = new SolidBrush(Color.Wheat);   Brush brush4 = new SolidBrush(Color.Orange);   Font font1 = new Font("Courier New", 16, FontStyle.Bold);   Font font2 = new Font("Courier New", 8);   g.FillRectangle(brush1, 0, 0, width, height); //绘制背景图   g.DrawString("公司员工年龄比例饼形图", font1, brush2, new Point(80, 20)); //书写标题   int piex = 100, piey = 60, piew = 200, pieh = 200;   //20-25岁员工在圆中分配的角度   float angle1 = Convert.ToSingle((360 / Convert.ToSingle(Sum)) * Convert.ToSingle(man20to25));   //26-30岁员工在圆中分配的角度   float angle2 = Convert.ToSingle((360 / Convert.ToSingle(Sum)) * Convert.ToSingle(man26to30));   //31-40岁员工在圆中分配的角度   float angle3 = Convert.ToSingle((360 / Convert.ToSingle(Sum)) * Convert.ToSingle(man31to40));   g.FillPie(brush2
    2022-04-12 00:35:45下载
    积分:1
  • C# 打印XPS文档 XPS文件打印
    C# 打印选择的XPS文档,打印XPS文件,相关代码如下:   private void button1_Click(object sender, RoutedEventArgs e)   {//打印选择的XPS文档    var MyDlg = new Microsoft.Win32.OpenFileDialog();    MyDlg.InitialDirectory = System.IO.Directory.GetCurrentDirectory();    MyDlg.Filter = "XPS文件(*.xps)|*.xps|所有文件(*.*)|*.*";    if (MyDlg.ShowDialog() == true)    {    string MyFileName = MyDlg.FileName;    var pDialog = new PrintDialog();    pDialog.PageRangeSelection = PageRangeSelection.AllPages;    pDialog.UserPageRangeEnabled = true;    if (pDialog.ShowDialog() == true)    {    var MyDocument = new System.Windows.Xps.Packaging.XpsDocument(MyFileName, System.IO.FileAccess.ReadWrite);    FixedDocumentSequence MyFixedDocumentSequence = MyDocument.GetFixedDocumentSequence();    pDialog.PrintDocument(MyFixedDocumentSequence.DocumentPaginator, "我的XPS打印文档");    }    }   }
    2022-03-23 09:37:24下载
    积分:1
  • C# 在程序中使用指针、十字光标、浮动窗口等不安全代
    C# 在程序中使用指针、十字光标、浮动窗口等不安全代码的实例,单击以下按钮会演示出对应功能:   在程序中显示一个浮动帮助窗口   显示等待光标   显示十字光标   对于功能实现,逐一分享源代码如下:在程序中使用指针等不安全代码:   var MyFileName = "C:atlog.txt";   var MyReader = new MyReaderClass(MyFileName);   const int MyBuffSize = 128;   byte[] MyBuffer = new byte[MyBuffSize];   ASCIIEncoding MyEncoder = new ASCIIEncoding();   var MyInfo = MyFileName + "的内容如下:";   while (MyReader.Read(MyBuffer, 0, MyBuffSize) != 0)    MyInfo += " " + MyEncoder.GetString(MyBuffer);   MessageBox.Show(MyInfo, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);   private void button2_Click(object sender, EventArgs e)   {//在程序中显示一个浮动帮助窗口    Help.ShowPopup(this, "提高程序开发效率、拓展软件应用领域", new Point(300, 350));   }   private void button3_Click(object sender, EventArgs e)   {//显示等待光标    this.Cursor = Cursors.WaitCursor;   }   private void button4_Click(object sender, EventArgs e)   {//显示十字光标    this.Cursor = Cursors.Cross;   }
    2023-05-20 08:40:02下载
    积分:1
  • C# 利用聚合函数MIN求销售额、利润最少的商品
    C# 利用聚合函数MIN求销售额、利润最少的商品,具体来说是查询利润最少的商品信息,查询销售额最少的商品信息,查询结果将绑定显示于DataGridView数据网格控件中。   下面以查询销售额最少的商品信息为例,帖出具体的代码实现:   private DataTable GetMoney()   {    string P_Str_ConnectionStr = string.Format(//创建数据库连接字符串    @"server=WIN-GI7E47AND9RLS;database=db_TomeTwo;uid=sa;pwd=");    string P_Str_SqlStr = string.Format(//创建SQL查询字符串    "SELECT * FROM tb_Ware WHERE 销价 IN(SELECT MIN(销价) FROM tb_Ware)");    SqlDataAdapter P_SqlDataAdapter = new SqlDataAdapter(//创建数据适配器    P_Str_SqlStr, P_Str_ConnectionStr);    DataTable P_dt = new DataTable();//创建数据表    P_SqlDataAdapter.Fill(P_dt);//填充数据表    return P_dt;//返回数据表   }   其它部分的查询请下载本源码包。
    2022-07-25 21:11:39下载
    积分:1
  • C# 使用Graphics对象在程序运行时创建位图
    C# 在程序运行时创建位图,本源码实例主要是学习使用使用Graphics对象创建简单图像的例子,本程序将生成一条曲线图像,参照如下代码:   {//在程序运行时创建位图   int MyWidth=this.pictureBox1.Width;   int MyHeight=this.pictureBox1.Height;   Bitmap MyBitmap = new Bitmap(MyWidth,MyHeight);   Graphics MyGraphics = Graphics.FromImage(MyBitmap);   Pen MyPen = new Pen(Color.Black, 3);   Point[] MyPoints = { new Point(50, 100), new Point(100, 10), new Point(150, 290), new Point(200, 100), new Point(250, 10), new Point(300, 290), new Point(350, 100) };   MyGraphics.Clear(Color.White);   MyGraphics.DrawBeziers(MyPen, MyPoints);   pictureBox1.Image = MyBitmap;
    2022-03-25 22:38:21下载
    积分:1
  • C# LoadAsync()异步加载并播放声音的例子
    C# 异步加载并播放声音文件的实例,异步加载主要是使用了LoadAsync(),使用IsLoadCompleted判断是否加载完成,加载完成则使用SoundPlayer()播放wav文件。在这个过程中,可能会有异常,因此这里添加了异常处理模块,当然了这是每个C#程序几乎都不可缺少的部分了,详情请下载本源码。   异步加载有很多好处,可节省系统资源,使软件执行速度更快,C#编程者,建议学习这项技巧哦。
    2023-02-10 15:50:03下载
    积分:1
  • 696518资源总数
  • 105549会员总数
  • 12今日下载