开发者

Is there any way to set the width of the dropdown in the DevExpress ComboBoxEdit for Windows Forms?

I'm using a DevExpress ComboBoxEdit to select a string. Some of the strings are very long, so they开发者_运维问答 take up the entire width of the screen, which works, but it's quite ugly. I'd much rather have a dropdown which is a fixed width, which either shows the full text when I hover over the item, or once it has been selected.

Any ideas?

Thanks


If you look under ComboBoxEdit.Properties, there is a PopupFormSize and PopupFormMinSize properties you can set.

Update:

Got it to work, but you have to set ComboBoxEdit.Properties.PopupSizable = true and handle the QueryPopUp event:

private void comboBoxEdit1_QueryPopUp(object sender, CancelEventArgs e)
{
  ComboBoxEdit cb = (ComboBoxEdit)sender;
  PropertyInfo pi = typeof(RepositoryItem).GetProperty("PropertyStore", BindingFlags.NonPublic | BindingFlags.Instance);
  HybridDictionary store = (HybridDictionary)pi.GetValue(cb.Properties, null);
  store["ComboPopupSize"] = new Size(100, 100);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜