コード例 #1
0
// <Snippet1>
    private void PrintPropertyDescriptions(BindingManagerBase b)
    {
        Console.WriteLine("Printing Property Descriptions");
        PropertyDescriptorCollection ps = b.GetItemProperties();

        for (int i = 0; i < ps.Count; i++)
        {
            Console.WriteLine("\t" + ps[i].Name + "\t" + ps[i].PropertyType);
        }
    }
コード例 #2
0
        /// <summary>
        /// Get the value of a binding.
        /// </summary>
        /// <typeparam name="T">Type of the value.</typeparam>
        /// <param name="binding">Binding to get value from.</param>
        /// <returns>Value from the binding.</returns>
        public static T As <T>(this Binding binding)
        {
            if (binding == null)
            {
                throw new ArgumentNullException(nameof(binding));
            }

            BindingManagerBase manager      = binding.BindingManagerBase;
            PropertyDescriptor itemProperty = manager.GetItemProperties().Find(binding.BindingMemberInfo.BindingField, true);

            return((T)itemProperty.GetValue(manager.Current));
        }
 private void InitializeBindingManagerAndItemProperties()
 {
     if (dataSource != null)
     {
         if (dataMember.Length > 0)
         {
             bindingManager = bindingContext[dataSource, dataMember];
         }
         else
         {
             bindingManager = bindingContext[dataSource];
         }
     }
     if (bindingManager != null)
     {
         itemProperties = bindingManager.GetItemProperties();
     }
 }
コード例 #4
0
 private void TrySubscribeControls()
 {
     foreach (Control control1 in (ArrangedElementCollection)this.PanelContainer.Controls)
     {
         RadPanel radPanel        = control1 as RadPanel;
         RadLabel label           = (RadLabel)null;
         RadLabel validationLabel = (RadLabel)null;
         if (radPanel != null)
         {
             label           = radPanel.Controls.Count > 0 ? radPanel.Controls[1] as RadLabel : (RadLabel)null;
             validationLabel = radPanel.Controls.Count > 2 ? radPanel.Controls[2] as RadLabel : (RadLabel)null;
         }
         List <Control> controlList = new List <Control>(ControlHelper.EnumChildControls(control1, true));
         controlList.Insert(0, control1);
         foreach (Control control2 in controlList)
         {
             if (control2.DataBindings.Count > 0 && control2.DataBindings[0].DataSource == this.DataSource)
             {
                 PropertyDescriptor property           = (PropertyDescriptor)null;
                 BindingManagerBase bindingManagerBase = control2.DataBindings[0].BindingManagerBase;
                 if (bindingManagerBase != null)
                 {
                     foreach (PropertyDescriptor itemProperty in bindingManagerBase.GetItemProperties())
                     {
                         if (itemProperty.Name == control2.DataBindings[0].BindingMemberInfo.BindingMember)
                         {
                             property = itemProperty;
                         }
                     }
                     if (property != null)
                     {
                         this.DataEntryElement.SubscribeControl(control1, property, label, validationLabel);
                     }
                 }
             }
         }
     }
 }