/// <summary> /// Raises the <c>TextChanged</c> event /// </summary> /// <param name="e">An <see cref="EventArgs"/> that contains the event data</param> protected override void OnTextChanged(EventArgs e) { // IMPORTANT: dont trigger this unless the event handler is hooked up or else the sizes will get out of sync. if (this.LabelHeightChanged != null && !dontExpand && !bChanging) { bChanging = true; int originalHeight = this.Height; int preferredWidth = this.ClientSize.Width; Size size = this.MeasureStringExtended(this.Text, this.Font, preferredWidth, minimumHeight); int newHeight = size.Height; this.Height = newHeight; LabelHeightChangedEventArgs args = new LabelHeightChangedEventArgs(originalHeight, newHeight); if (args.HeightChange != 0) { this.LabelHeightChanged(args); } base.OnTextChanged(e); bChanging = false; } else { this.minimumHeight = this.Height; base.OnTextChanged(e); } }
/// <summary> /// Raises the <c>TextChanged</c> event /// </summary> /// <param name="e">An <see cref="EventArgs"/> that contains the event data</param> protected override void OnTextChanged(EventArgs e) { // IMPORTANT: dont trigger this unless the event handler is hooked up or else the sizes will get out of sync. if(this.LabelHeightChanged != null && !dontExpand && !bChanging) { bChanging = true; int originalHeight = this.Height; int preferredWidth = this.ClientSize.Width; Size size = this.MeasureStringExtended(this.Text, this.Font, preferredWidth, minimumHeight); int newHeight = size.Height; this.Height = newHeight; LabelHeightChangedEventArgs args = new LabelHeightChangedEventArgs(originalHeight, newHeight); if (args.HeightChange != 0) { this.LabelHeightChanged(args); } base.OnTextChanged(e); bChanging = false; } else { this.minimumHeight = this.Height; base.OnTextChanged(e); } }
/// <summary> /// Raises the <c>TextChanged</c> event /// </summary> /// <param name="e">An <see cref="EventArgs"/> that contains the event data</param> protected override void OnTextChanged(EventArgs e) { if (!dontExpand && !bChanging) { bChanging = true; int originalHeight = this.Height; int preferredWidth = this.ClientSize.Width; Size size = this.MeasureStringExtended(this.Text, this.Font, preferredWidth, this.Height); int newHeight = size.Height; this.Height = newHeight; LabelHeightChangedEventArgs args = new LabelHeightChangedEventArgs(originalHeight, newHeight); if (args.HeightChange != 0 && this.LabelHeightChanged != null) { this.LabelHeightChanged(args); } base.OnTextChanged(e); bChanging = false; } else { base.OnTextChanged(e); } }