c# - Showing ellipsis in GroupBox, when text is too long? -


radiobutton , checkbox have wraptext property. when enabled, text, long control, gets wrapped. when disabled, ellipsis appears @ end.

label has autoelipsis property same thing, except has enabled ellipsis show.

how force same behavior in groupbox?

there go, created custom control you. use instead of groupbox, can enable/disable autoelipsis through designer properties or in code.

public class elipsisgroupbox : groupbox {     private string _temptext;     private bool _iselipsison;      public elipsisgroupbox () : base()     {         _temptext = string.empty;         _iselipsison = false;     }      protected override void onresize(eventargs e)     {         base.onresize(e);          if (this.autoelipsis)         {             _temptext = base.text;             if (_temptext.length == 0 || base.width == 0)                 return;              int = _temptext.length;              string texttocheck = _iselipsison ? _temptext : _temptext + "...";              _iselipsison = false;             while (textrenderer.measuretext(texttocheck, base.font).width > (base.width - 14))             {                 _iselipsison = true;                 texttocheck = base.text.substring(0, --i) + "...";                 if (i == 0)                     break;             }              if (_iselipsison)                 _temptext = texttocheck;         }     }      public override string text     {                 {             return this.autoelipsis && _iselipsison ? _temptext : base.text;         }         set         {             if (this.autoelipsis && _iselipsison)                 _temptext = value;             else                 base.text = value;         }     }      public bool autoelipsis { get; set; } } 

Comments