I'm attempting (for reasons) to use a cue banner textbox in place of the standard textbox in a WinForms dropdown item.
I've gotten it to a state where I can add the new control object to the list of dropdown options, but if I do, it locks up the properties menu for not only it, but also any other options on that same dropdown 'list'. It does not have this issue if I use it elsewhere in the form - just when its used in a dropdown.
I'm posting two pieces of code below:
- My CueTextBox class (extend TextBox)
My ToolStripCueTextBox class (derive from ToolStripControlHost for designer availability)
**//1 - Class for box** public class CueTextBox : TextBox { private string mCue; public string Cue { get => mCue; set { mCue = value; Invalidate(); } } protected override void WndProc(ref Message m) { base.WndProc(ref m); const int WM_PAINT = 0xF; if (m.Msg == WM_PAINT) { if (!Focused && string.IsNullOrEmpty(Text) && !string.IsNullOrEmpty(Cue)) { using (var graphics = CreateGraphics()) { TextRenderer.DrawText( dc: graphics, text: Cue, font: Font, bounds: ClientRectangle, foreColor: SystemColors.GrayText, backColor: Enabled ? BackColor : SystemColors.Control, flags: TextFormatFlags.Top | TextFormatFlags.Left); } } } } **//2 - Class for toolstrip** [ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.All)] public class ToolStripCueTextBoxItem : ToolStripControlHost { public ToolStripCueTextBoxItem() : base(new CueTextBox()) { } }
I'm new here, but any help would be greatly appreciated!