WPF ComboBox without drop-down button

It’s possible, but you would need to retemplate it to achieve perfection. You can get most of the way there by overriding a system parameter as follows: <ComboBox xmlns:sys=”clr-namespace:System;assembly=mscorlib”> <ComboBox.Resources> <sys:Double x:Key=”{x:Static SystemParameters.VerticalScrollBarWidthKey}”>0</sys:Double> </ComboBox.Resources> <ComboBoxItem>One</ComboBoxItem> <ComboBoxItem>Two</ComboBoxItem> <ComboBoxItem>Three</ComboBoxItem> </ComboBox> However, it isn’t perfect because the focus rectangle still assumes there is a drop-down button present.

Disabling particular Items in a Combobox

Try this… Does it serve your purpose: I assume you have a combobox called ComboBox1 and you want to disable the second item i.e. an item with index 1. Set the DrawMode property of the combobox to OwnerDrawFixed then handle these two events as shown below: Font myFont = new Font(“Aerial”, 10, FontStyle.Regular); private void … Read more

How to prevent/cancel a combobox’s value change in c#?

Save the ComboBox’s SelectedIndex when to box if first entered, and then restore it’s value when you need to cancel the change. cbx_Example.Enter += cbx_Example_Enter; cbx_Example.SelectionChangeCommitted += cbx_Example_SelectionChangeCommitted; … private int prevExampleIndex = 0; private void cbx_Example_Enter(object sender, EventArgs e) { prevExampleIndex = cbx_Example.SelectedIndex; } private void cbx_Example_SelectionChangeCommitted(object sender, EventArgs e) { // some custom … Read more

Extjs 4 combobox default value

I had the same problem, afaik has to do with selectlist rendering before the items are added to the store. I tried the callback method mentioned above without any luck (guess it would have to be a callback on the selectlist rather than the store). I added this line after adding items to the store … Read more

Why can’t I select a null value in a ComboBox?

Well I recently ran into the same problem with null value for ComboBox. I’ve solved it by using two converters: For ItemsSource property: it replaces null values in the collection by any value passed inside converter’s parameter: class EnumerableNullReplaceConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var collection … Read more

Auto-width of ComboBox’s content

You can’t use it directly. Do a trick First iterate through all items of your combobox, check for the width of every items by assigning the text to a label. Then, check width every time, if width of current item gets greater than previous items then change the maximum width. int DropDownWidth(ComboBox myCombo) { int … Read more

WPF ComboBox performance problems by binding a large collections

According to this blog: http://vbcity.com/blogs/xtab/archive/2009/12/15/wpf-using-a-virtualizingstackpanel-to-improve-combobox-performance.aspx I’ve tested it with this code: <ComboBox Name=”cbBlah” ItemsSource=”{Binding}”> <ComboBox.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel /> </ItemsPanelTemplate> </ComboBox.ItemsPanel> </ComboBox> It works fine for first time and next times. It’s not necessary to code these lines: <VirtualizingStackPanel VirtualizingStackPanel.IsVirtualizing=”True” VirtualizingStackPanel.VirtualizationMode=”Recycling” />