zoukankan      html  css  js  c++  java
  • C# WPF 之 遍历子控件

     /// <summary>
            /// 检查非空字段
            /// </summary>
            /// <param name="IsOk"></param>
            /// <param name="textboxes"></param>
            private void CheckTextBoxNotNull(ref bool IsOk, params TextBox[] textboxes)
            {
                foreach (TextBox txtBox in textboxes)
                {
                    txtBox.Background = Brushes.White;
                    if (txtBox.Text.Length <= 0)
                    {
                        IsOk = false;
                        txtBox.Background = Brushes.Red;
                    }
                    else
                    {
                        txtBox.Background = null;
                    }
                }
            }
    /// <summary>
            /// 设置控件
            /// </summary>
            /// <param name="IsEn"></param>
            /// <param name="IsNull"></param>
            private void SetControl(bool IsEn ,bool IsNull)
            {
                foreach (UIElement c in grd_UserInfo.Children)
                {
                    if (c is TextBox)
                    {
                        c.IsEnabled = IsEn;
                        if (IsNull)
                        {
                            ((TextBox)c).Text = "";
                        }
                    }
                    if (c is ComboBox)
                    {
                        c.IsEnabled = IsEn;
                        if (IsNull)
                        {
                            ((ComboBox)c).SelectedIndex = -1;
                        }
                    }
                    if (c is DatePicker)
                    {
                        c.IsEnabled = IsEn;
                        if (IsNull)
                        {
                            ((DatePicker)c).SelectedDate = null;
                        }
                    }
                }
                btn_ChoosePhoto.IsEnabled = IsEn;
            }
    /// <summary>
            /// 验证邮箱输入是否合法
            /// </summary>
            /// <param name="strIn"></param>
            /// <returns></returns>
            private bool IsValidEmail(string strIn)
            {
                return Regex.IsMatch(strIn, @"^([w-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([w-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)$");
            }
  • 相关阅读:
    突破ASLR之理论篇
    安装cocoaPods
    iOS 文字渐变
    iOS_科大讯飞快速实现语音搜索功能Demo
    Button宽度自定义
    全局手势按钮(随意拖动,点击事件)
    文字广告轮播这个就够用了
    一些有趣的三方开源库
    SVN的简单使用和积累
    如何在手机上面安装iPA应用包
  • 原文地址:https://www.cnblogs.com/fengyie55/p/3865430.html
Copyright © 2011-2022 走看看