Bloom.CollectionTab.ListHeader.AdjustWidth C# (CSharp) Method

AdjustWidth() public method

public AdjustWidth ( ) : void
return void
        public void AdjustWidth()
        {
            using (var g = CreateGraphics())
            {
                var size = g.MeasureString(Label.Text, Label.Font);
                Width = (int)size.Width + 6;
            }
        }

Usage Example

        /// <summary>
        /// the primary could as well be called "the one editable collection"... the one at the top
        /// </summary>
        private void LoadPrimaryCollectionButtons()
        {
            _primaryCollectionReloadPending = false;
            _primaryCollectionFlow.SuspendLayout();
            _primaryCollectionFlow.Controls.Clear();
            //without this guy, the FLowLayoutPanel uses the height of a button, on *the next row*, for the height of this row!
            var invisibleHackPartner = new Label()
            {
                Text = "", Width = 0
            };

            _primaryCollectionFlow.Controls.Add(invisibleHackPartner);
            var primaryCollectionHeader = new ListHeader()
            {
                ForeColor = Palette.TextAgainstDarkBackground
            };

            primaryCollectionHeader.Label.Text = _model.VernacularLibraryNamePhrase;
            primaryCollectionHeader.AdjustWidth();
            _primaryCollectionFlow.Controls.Add(primaryCollectionHeader);
            //_primaryCollectionFlow.SetFlowBreak(primaryCollectionHeader, true);
            _primaryCollectionFlow.Controls.Add(_menuTriangle);            //NB: we're using a picture box instead of a button because the former can have transparency.
            LoadOneCollection(_model.GetBookCollections().First(), _primaryCollectionFlow);
            _primaryCollectionFlow.ResumeLayout();
        }
All Usage Examples Of Bloom.CollectionTab.ListHeader::AdjustWidth