zoukankan      html  css  js  c++  java
  • 扩展方法应用

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;

    namespace TaskManager
    {
        
    public static class ValidateHelper
        
    {
            
    static ValidateHelper()
            
    {
                IsErr 
    = false;
            }


            
    public static bool IsErr
            
    {
                
    get;
                
    set;
            }

            
    static ErrorProvider ep = new ErrorProvider();
            
    public static bool Validate(this TextBox ctrl, System.Func<TextBox, bool> func, string errmsg)
            
    {
                
    if (!func(ctrl))
                
    {
                    ep.SetError(ctrl, errmsg);
                    ctrl.Focus();

                    
    return !(IsErr=true);
                }

                
    return true;
            }

            
    public static bool Validate(this ListBox ctrl, System.Func<ListBox, bool> func, string errmsg)
            
    {
                
    if (!func(ctrl))
                
    {
                    ep.SetError(ctrl, errmsg);
                    ctrl.Focus();

                    
    return !(IsErr = true);
                }

                
    return true;
            }

            
    public static void Clear()
            
    {
                ep.Clear();
                IsErr 
    = false;
            }

        }

    }

    还是照样上两张图

    用法

    Code

    相关文章链接:

    C#学习使用ErrorProvider

    http://www.cnblogs.com/sondy/archive/2006/04/16/376254.html

    ErrorProvider的用法

    http://www.cnblogs.com/sondy/archive/2006/04/16/376254.html

    验证能有多优雅

    http://www.cnblogs.com/GrayZhang/archive/2008/09/01/1281526.html

  • 相关阅读:
    工作流调度器azkaban
    日志采集框架Flume
    MAPREDUCE框架结构及核心运行机制
    Python爬虫开发系列之五》数据存储为TXT、JSON格式
    Python爬虫开发系列之二》请求库及解析库安装
    策略模式+简单工厂模式
    简单工厂模式
    单例模式
    5、计算高可用
    4、存储高可用
  • 原文地址:https://www.cnblogs.com/lexus/p/1274729.html
Copyright © 2011-2022 走看看