Exemple #1
0
        public BindingListDisplay(BindingList <TType> contents, Func <TType, Control> funcCreateControl, bool blnLoadVisibleOnly = true)
        {
            InitializeComponent();
            Contents            = contents ?? throw new ArgumentNullException(nameof(contents));
            _funcCreateControl  = funcCreateControl;
            _blnLoadVisibleOnly = blnLoadVisibleOnly;
            DisplayPanel.SuspendLayout();
            try
            {
                int intMaxControlHeight = 0;
                foreach (TType objLoopTType in Contents)
                {
                    ControlWithMetaData objNewControl = new ControlWithMetaData(objLoopTType, this, false);
                    intMaxControlHeight = Math.Max(objNewControl.Control.PreferredSize.Height, intMaxControlHeight);
                    _lstContentList.Add(objNewControl);
                }

                if (intMaxControlHeight > 0)
                {
                    ListItemControlHeight = intMaxControlHeight;
                }

                DisplayPanel.Controls.AddRange(_lstContentList.Select(x => x.Control).ToArray());
                _indexComparer        = new IndexComparer(Contents);
                _comparison           = _comparison ?? _indexComparer;
                Contents.ListChanged += ContentsChanged;
                ComputeDisplayIndex();
                LoadScreenContent();
                BindingListDisplay_SizeChanged(null, null);
            }
            finally
            {
                _blnIsTopmostSuspendLayout = true;
                DisplayPanel.ResumeLayout();
            }
        }