Question CustomCollectionEditor - Couple of Questions

Chichak

New member
Joined
May 8, 2022
Messages
2
Programming Experience
Beginner
Question: When I open Form from Properties window of Composite control, I can add, delete fields but when I add field DataField property have empty DropDown.
How Can I get List of Fields that is defined inmy CompositeControl with DataSourceID?


C#:
namespace uOfficeServerControls
{
    public class uOfficeDataControlFieldCollectionEditorForm : CollectionEditor
    {
        private DataControlFieldCollection collection;

        public uOfficeDataControlFieldCollectionEditorForm(Type type) : base(type)
        {       
        }
        protected override CollectionForm CreateCollectionForm()
        {
            CollectionForm collectionForm = base.CreateCollectionForm();      
            collectionForm.BackColor = System.Drawing.Color.Gray;
            return collectionForm;
        }

        protected override object CreateInstance(Type itemType)
        {
            if (itemType == typeof(BoundField)) { return new BoundField(); }
            else if (itemType == typeof(ImageField)) { return new ImageField(); }
            else if (itemType == typeof(ButtonField)) { return new ButtonField(); }
            else if (itemType == typeof(CommandField)) { return new CommandField(); }
            else if (itemType == typeof(TemplateField)) { return new TemplateField(); }
            else if (itemType == typeof(CheckBoxField)) { return new CheckBoxField(); }
            else if (itemType == typeof(HyperLinkField)) { return new HyperLinkField(); }
            else if (itemType == typeof(ImageField)) { return new ImageField(); }
            else if (itemType == typeof(uGridViewField)) { return new uGridViewField("1", "2"); }
            else if (itemType == typeof(uGridViewRadioButtonField)) { return new uGridViewRadioButtonField(); }
            else
            {
                var constructor = itemType.GetConstructors().FirstOrDefault();
                if (constructor != null)
                {
                    var parameters = constructor.GetParameters();
                    var args = parameters.Select(p => Type.Missing).ToArray();
                    return Activator.CreateInstance(itemType, args);
                }
            }
            return null;
        }

        protected override Type[] CreateNewItemTypes()
        {
            return new Type[] { typeof(BoundField), typeof(ImageField), typeof(ButtonField), typeof(CommandField), typeof(TemplateField), typeof(CheckBoxField),
                                typeof(HyperLinkField), typeof(uGridViewField), typeof(uGridViewRadioButtonField) };
        }

        public DataControlFieldCollection Collection
        {
            get { return collection; }
            set { collection = value; }
        }

        #region CustomFields
      
        public sealed class uGridViewField
        {
            ....
        }

        public sealed class uGridViewRadioButtonField : CheckBoxField
        {
              ......
                cell.Controls.Add(radio);
            }
        }

        #endregion
    }
}
 
Last edited by a moderator:

Latest posts

Back
Top Bottom