C# WPF ComboBox - Exclude last row (or Blank Space) of Binding Data (binding from Microsoft Access)

前端 未结 3 1561
你的背包
你的背包 2021-01-16 07:59

Currently I am using Microsoft Access to keep the data and it will bind to WPF combobox. Below code was working almost fine.

oleDBCommand.CommandText =

\"SE         


        
相关标签:
3条回答
  • 2021-01-16 08:21

    The combobox will only show the objects you give it, take a closer look at the data coming out of your query. You may need to add an additional filter in the where clause to exclude rows with empty values.

    0 讨论(0)
  • 2021-01-16 08:26

    This might be an old thread but I had the same issue with ComboBox. The thing is ComboBox align items to the TOP so it's not an extra item or line. It's just the space left after publishing your items. So let's say if your combobox height is 37 px and height of each item is 10px then you will see that last space of 7 px. Try keeping the height of combobox same as that of its individual elements.

     <ComboBox Width="200"
           Height="50"
           ItemsSource="{Binding MyList}">
        <ComboBox.ItemContainerStyle>
            <Style TargetType="ComboBoxItem">
                <Setter Property="Height" Value="50" />
                <Setter Property="Width" Value="50" />
            </Style>
        </ComboBox.ItemContainerStyle>
    

    0 讨论(0)
  • 2021-01-16 08:32

    Try setting ScrollViewer.CanContentScroll="False" on your ComboBox.

    0 讨论(0)
提交回复
热议问题