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. WCF and WF
  4. A listview inside a combo box

A listview inside a combo box

Scheduled Pinned Locked Moved WCF and WF
help
3 Posts 1 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.
  • D Offline
    D Offline
    dashingsidds
    wrote on last edited by
    #1

    Hi Experts, I am not sure if i would be able to explain my problem efficiently or not but yeah will definitely try. I have a user control which contains a combo box. I have added a listview inside the combo box as cboComboBoxControl.Items.Add(lstvMyView);. I have also handled the selection changed event of the list view so that when the selection gets changed the text area of the combo box gets populated with one of the column given in the list view. I have done this as

        void lstvMyView\_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DataRowView drv = (DataRowView)lstvMyView.SelectedValue;
            cboComboBoxControl.Text = drv.Row\["TextCol"\].ToString();
        }
    

    Now when i run the code and keep my mouse clicked (left mouse button is down and is not yet released) on a row in the listview the text gets changed to the desired value but as soon as i leave my left mouse button the value in the text gets changed to "System.Windows.Controls.ListView Items.Count:2" i.e. it shows me the number of rows in the listview. Anyone please help! Thanks in advance! Regards, Samar

    D 2 Replies Last reply
    0
    • D dashingsidds

      Hi Experts, I am not sure if i would be able to explain my problem efficiently or not but yeah will definitely try. I have a user control which contains a combo box. I have added a listview inside the combo box as cboComboBoxControl.Items.Add(lstvMyView);. I have also handled the selection changed event of the list view so that when the selection gets changed the text area of the combo box gets populated with one of the column given in the list view. I have done this as

          void lstvMyView\_SelectionChanged(object sender, SelectionChangedEventArgs e)
          {
              DataRowView drv = (DataRowView)lstvMyView.SelectedValue;
              cboComboBoxControl.Text = drv.Row\["TextCol"\].ToString();
          }
      

      Now when i run the code and keep my mouse clicked (left mouse button is down and is not yet released) on a row in the listview the text gets changed to the desired value but as soon as i leave my left mouse button the value in the text gets changed to "System.Windows.Controls.ListView Items.Count:2" i.e. it shows me the number of rows in the listview. Anyone please help! Thanks in advance! Regards, Samar

      D Offline
      D Offline
      dashingsidds
      wrote on last edited by
      #2

      Hi Experts any thoughts on this..??? Please do let me know if you need any other input from my side. Regards, Samar

      1 Reply Last reply
      0
      • D dashingsidds

        Hi Experts, I am not sure if i would be able to explain my problem efficiently or not but yeah will definitely try. I have a user control which contains a combo box. I have added a listview inside the combo box as cboComboBoxControl.Items.Add(lstvMyView);. I have also handled the selection changed event of the list view so that when the selection gets changed the text area of the combo box gets populated with one of the column given in the list view. I have done this as

            void lstvMyView\_SelectionChanged(object sender, SelectionChangedEventArgs e)
            {
                DataRowView drv = (DataRowView)lstvMyView.SelectedValue;
                cboComboBoxControl.Text = drv.Row\["TextCol"\].ToString();
            }
        

        Now when i run the code and keep my mouse clicked (left mouse button is down and is not yet released) on a row in the listview the text gets changed to the desired value but as soon as i leave my left mouse button the value in the text gets changed to "System.Windows.Controls.ListView Items.Count:2" i.e. it shows me the number of rows in the listview. Anyone please help! Thanks in advance! Regards, Samar

        D Offline
        D Offline
        dashingsidds
        wrote on last edited by
        #3

        Hi Experts I got the solution for this. I added the MouseLeftButtonUp Event and added the following code.

            void lstvMyView\_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
            {
                e.Handled = true;
            }
        

        Because of this the drop down would not close when the selection in the listview gets changed. So I added "IsDropDownOpen" = false on selection changed event of listview as

            void lstvMyView\_SelectionChanged(object sender, SelectionChangedEventArgs e)
            {
                DataRowView drv = (DataRowView)lstvMyView.SelectedValue;
                cboComboBoxControl.Text = drv.Row\["TextCol"\].ToString();
        
                cboComboBoxControl.IsDropDownOpen = false;
            }
        

        I guess everyone knew i would finally get it!!! Isnt it??? :laugh: Thanks anyways!! Regards, Samar

        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