Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. WPF Combobox not navigating to items on key press

WPF Combobox not navigating to items on key press

Scheduled Pinned Locked Moved WPF
csharpwpfcsswcfhelp
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    S Rajput
    wrote on last edited by
    #1

    Hi.. Inside my code the combobox is not responding to key press events.. like if user presses M, combobox should select Marrylands in the dropdownlist like the ASP .net combobox does. Can anyone please help??? <ComboBox HorizontalAlignment="Right" Height="23" Name="cmbPortsFrom" KeyDown="cmbPortsFrom_KeyDown" Width="105" SelectedIndex="0" Grid.Row="2" Grid.Column="0" > <ComboBox.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel /> </ItemsPanelTemplate> </ComboBox.ItemsPanel> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Path=Code}" FontSize="15" Height="20"/> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> codebehind: Dim lDataSource2 As ICollection(Of BusinessLayer.Ports) lDataSource2 = mBalObjPorts.getPortData() Me.cmbPortsFrom.ItemsSource = lDataSource2

    A 1 Reply Last reply
    0
    • S S Rajput

      Hi.. Inside my code the combobox is not responding to key press events.. like if user presses M, combobox should select Marrylands in the dropdownlist like the ASP .net combobox does. Can anyone please help??? <ComboBox HorizontalAlignment="Right" Height="23" Name="cmbPortsFrom" KeyDown="cmbPortsFrom_KeyDown" Width="105" SelectedIndex="0" Grid.Row="2" Grid.Column="0" > <ComboBox.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel /> </ItemsPanelTemplate> </ComboBox.ItemsPanel> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Path=Code}" FontSize="15" Height="20"/> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> codebehind: Dim lDataSource2 As ICollection(Of BusinessLayer.Ports) lDataSource2 = mBalObjPorts.getPortData() Me.cmbPortsFrom.ItemsSource = lDataSource2

      A Offline
      A Offline
      ABitSmart
      wrote on last edited by
      #2

      SR81 wrote:

      KeyDown="cmbPortsFrom_KeyDown"

      What are you doing in the keydown event ?

      S 1 Reply Last reply
      0
      • A ABitSmart

        SR81 wrote:

        KeyDown="cmbPortsFrom_KeyDown"

        What are you doing in the keydown event ?

        S Offline
        S Offline
        S Rajput
        wrote on last edited by
        #3

        apparently nothing, its an empty function.I believe the combobox should automatically select Marrylands from the list if user presses "M" key??

        C A 2 Replies Last reply
        0
        • S S Rajput

          apparently nothing, its an empty function.I believe the combobox should automatically select Marrylands from the list if user presses "M" key??

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Perhaps your empty event is preventing this from occuring ?

          Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

          S 1 Reply Last reply
          0
          • C Christian Graus

            Perhaps your empty event is preventing this from occuring ?

            Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

            S Offline
            S Offline
            S Rajput
            wrote on last edited by
            #5

            I have removed the function, still its not working. It could be because the combobox contains nearlly 500 rows? Anyhow i am writing the keypress event function to achieve this. Thanks.

            A 1 Reply Last reply
            0
            • S S Rajput

              apparently nothing, its an empty function.I believe the combobox should automatically select Marrylands from the list if user presses "M" key??

              A Offline
              A Offline
              ABitSmart
              wrote on last edited by
              #6

              If you are going to use a just a TextBox then do it this way,

              <ComboBox x:Name="myComboBox" IsEditable="true" DisplayMemberPath="Code" Height="266" >
              <ComboBox.ItemsPanel>
              <ItemsPanelTemplate>
              <VirtualizingStackPanel />
              </ItemsPanelTemplate>
              </ComboBox.ItemsPanel>
              </ComboBox>

              If no, you would have to implement the functionality on KeyDown event (specifically by overriding OnPreviewKeyDown). This[^] might be of help.

              S 1 Reply Last reply
              0
              • S S Rajput

                I have removed the function, still its not working. It could be because the combobox contains nearlly 500 rows? Anyhow i am writing the keypress event function to achieve this. Thanks.

                A Offline
                A Offline
                ABitSmart
                wrote on last edited by
                #7

                SR81 wrote:

                It could be because the combobox contains nearlly 500 rows?

                That doesn't seem logical. Perhaps because changes to VisualTree will be making it difficult to decide what to use as SelectedValuePath. Just a guess.

                1 Reply Last reply
                0
                • A ABitSmart

                  If you are going to use a just a TextBox then do it this way,

                  <ComboBox x:Name="myComboBox" IsEditable="true" DisplayMemberPath="Code" Height="266" >
                  <ComboBox.ItemsPanel>
                  <ItemsPanelTemplate>
                  <VirtualizingStackPanel />
                  </ItemsPanelTemplate>
                  </ComboBox.ItemsPanel>
                  </ComboBox>

                  If no, you would have to implement the functionality on KeyDown event (specifically by overriding OnPreviewKeyDown). This[^] might be of help.

                  S Offline
                  S Offline
                  S Rajput
                  wrote on last edited by
                  #8

                  Thanks,that just gave me an idea of creating an AJax listsearch extender kind of control in WPF. Cheers

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups