By design. When the Style = DropDown, the text portion of the combobox is a TextBox. Which displays the cue banner in non-italic style. You can verify with this code. It is otherwise important to make the distinction between the banner and the actual selection visible when the Style = DropDownList, no doubt the reason they chose to display it italic. TextBox does it differently, it hides the banner when it gets the focus.
Throwing in a non exhausting version:
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
class CueComboBox : ComboBox {
private string mCue;
public string Cue {
get { return mCue; }
set {
mCue = value;
updateCue();
}
}
private void updateCue() {
if (this.IsHandleCreated && mCue != null) {
SendMessage(this.Handle, 0x1703, (IntPtr)0, mCue);
}
}
protected override void OnHandleCreated(EventArgs e) {
base.OnHandleCreated(e);
updateCue();
}
// P/Invoke
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, string lp);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…