当前位置: 首页>>代码示例>>C#>>正文


C# Binding.ReadValue方法代码示例

本文整理汇总了C#中Binding.ReadValue方法的典型用法代码示例。如果您正苦于以下问题:C# Binding.ReadValue方法的具体用法?C# Binding.ReadValue怎么用?C# Binding.ReadValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Binding的用法示例。


在下文中一共展示了Binding.ReadValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ApplyWriteRules

    private void ApplyWriteRules(
      Control ctl, Binding binding,
      bool canWrite)
    {
      if (ctl is Label) return;

      // enable/disable writing of the value
      PropertyInfo propertyInfo =
        ctl.GetType().GetProperty("ReadOnly",
        BindingFlags.FlattenHierarchy |
        BindingFlags.Instance |
        BindingFlags.Public);
      if (propertyInfo != null)
      {
        bool couldWrite =
          (!(bool)propertyInfo.GetValue(
          ctl, new object[] { }));
        propertyInfo.SetValue(
          ctl, !canWrite, new object[] { });
        if ((!couldWrite) && (canWrite))
          binding.ReadValue();
      }
      else
      {
        bool couldWrite = ctl.Enabled;
        ctl.Enabled = canWrite;
        if ((!couldWrite) && (canWrite))
          binding.ReadValue();
      }
    }
开发者ID:transformersprimeabcxyz,项目名称:cslacontrib-MarimerLLC,代码行数:30,代码来源:ReadWriteAuthorization.cs

示例2: ApplyReadRules

    private void ApplyReadRules(
      Control ctl, Binding binding,
      bool canRead)
    {
      var status = GetControlStatus(ctl);

      // enable/disable reading of the value
      if (canRead)
      {
        ctl.Enabled = true;
        // if !CanRead remove format event and refresh value 
        if (!status.CanRead)
        {
          binding.Format -= ReturnEmpty;
          binding.ReadValue();
        }
      }
      else
      {
        ctl.Enabled = false;
        if (status.CanRead)
        {
          binding.Format += ReturnEmpty;
        }

        // clear the value displayed by the control
        var propertyInfo = ctl.GetType().GetProperty(binding.PropertyName,
          BindingFlags.FlattenHierarchy |
          BindingFlags.Instance |
          BindingFlags.Public);
        if (propertyInfo != null)
        {
          propertyInfo.SetValue(ctl,
            GetEmptyValue(
            Utilities.GetPropertyType(
              propertyInfo.PropertyType)),
            new object[] { });
        }
      }

      // store new status
      status.CanRead = canRead;
    }
开发者ID:transformersprimeabcxyz,项目名称:cslacontrib-MarimerLLC,代码行数:43,代码来源:ReadWriteAuthorization.cs


注:本文中的Binding.ReadValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。