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. C / C++ / MFC
  4. How to update the selected item path in ComboBox

How to update the selected item path in ComboBox

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialannouncement
10 Posts 5 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.
  • A Offline
    A Offline
    Anamika2005
    wrote on last edited by
    #1

    Can somebody help me in the case that i want that the path of the selected item in the treecrtl should get updated or what we say get selected inthe combobox box .. How to achieve that.... Thanks in Advance Saniaaa

    _ V M H 4 Replies Last reply
    0
    • A Anamika2005

      Can somebody help me in the case that i want that the path of the selected item in the treecrtl should get updated or what we say get selected inthe combobox box .. How to achieve that.... Thanks in Advance Saniaaa

      _ Offline
      _ Offline
      _AnsHUMAN_
      wrote on last edited by
      #2

      saniaa wrote:

      what we say get selected inthe combobox box ..

      CComboBox::GetCurSel(); or if you want to Search for a string in the list box of a combo box and, if the string is found, select the string in the list box and copy the string to the edit control you can use, CComboBox::SelectString();

      Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

      A 1 Reply Last reply
      0
      • A Anamika2005

        Can somebody help me in the case that i want that the path of the selected item in the treecrtl should get updated or what we say get selected inthe combobox box .. How to achieve that.... Thanks in Advance Saniaaa

        V Offline
        V Offline
        VCSharp007
        wrote on last edited by
        #3

        Here it is. CString csTreeItem = m_ObjTree.GetItemText(m_ObjTree.GetSelectedItem()); CString csComboItem; for( int nInd =0; nInd < m_ObjCombo.GetCount(); nInd++ ) { ObjCombo.GetLBText(nInd, csComboItem); if( 0 == csComboItem.compare(csTreeItem )) { ObjCombo.SetCurSel(nInd ); break; } }

        A 1 Reply Last reply
        0
        • V VCSharp007

          Here it is. CString csTreeItem = m_ObjTree.GetItemText(m_ObjTree.GetSelectedItem()); CString csComboItem; for( int nInd =0; nInd < m_ObjCombo.GetCount(); nInd++ ) { ObjCombo.GetLBText(nInd, csComboItem); if( 0 == csComboItem.compare(csTreeItem )) { ObjCombo.SetCurSel(nInd ); break; } }

          A Offline
          A Offline
          Anamika2005
          wrote on last edited by
          #4

          Thanks for ur reply.. Acccording to ur way as per my understanding my combobox should have the selected item from the treectrl in its datalist ,and then comparing it with the one selected , it is updating in comboboox. But if i have the simple combbox datalist which just have the datlist items like C:\ ,D:\ not the whole contents of the drives ... in such sitution do we manage it ??? Thanks Saniaa

          V 1 Reply Last reply
          0
          • _ _AnsHUMAN_

            saniaa wrote:

            what we say get selected inthe combobox box ..

            CComboBox::GetCurSel(); or if you want to Search for a string in the list box of a combo box and, if the string is found, select the string in the list box and copy the string to the edit control you can use, CComboBox::SelectString();

            Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

            A Offline
            A Offline
            Anamika2005
            wrote on last edited by
            #5

            Thanks for ur reply ... The Datlist of the combobox does not contain the item which is get selected in the treectrl . The way u have given is for that situation. Here combobox just contain C:\,D:\ like this dataitems in it. and when the selection in the treectrl gets changed i want the changed or selected item path should get updated in the combobox . Is there any way to achieve this.. Thanks Shikha

            1 Reply Last reply
            0
            • A Anamika2005

              Can somebody help me in the case that i want that the path of the selected item in the treecrtl should get updated or what we say get selected inthe combobox box .. How to achieve that.... Thanks in Advance Saniaaa

              M Offline
              M Offline
              Mila025
              wrote on last edited by
              #6

              Hi, I'm not sure ... you've got a combobox only with drive letters and on treectrl full path, and when you select some path on tree, in combobox should appear full path ? If yes: - HTREEITEM GetSelectedItem() - you'll get selected item handle - CString GetItemText( HTREEITEM hItem ) - you'll get item text - HTREEITEM GetParentItem( HTREEITEM hItem ) - you'll get parents' item handle - CString GetItemText( HTREEITEM hItem ) - you'll get item text ... unless your parents' item handle will equal with root - HTREEITEM GetRootItem( ) when you'll get all path, you can send all text to combobox - int InsertString( int nIndex, LPCTSTR lpszString ) and select - int SetCurSel( int nSelect );

              ----------- Mila

              1 Reply Last reply
              0
              • A Anamika2005

                Thanks for ur reply.. Acccording to ur way as per my understanding my combobox should have the selected item from the treectrl in its datalist ,and then comparing it with the one selected , it is updating in comboboox. But if i have the simple combbox datalist which just have the datlist items like C:\ ,D:\ not the whole contents of the drives ... in such sitution do we manage it ??? Thanks Saniaa

                V Offline
                V Offline
                VCSharp007
                wrote on last edited by
                #7

                Sorry. I don't get ur need clearly. if the selected tree control item not in ur combo box, You want to add it in the combo and select that one?? or map to any other item??

                1 Reply Last reply
                0
                • A Anamika2005

                  Can somebody help me in the case that i want that the path of the selected item in the treecrtl should get updated or what we say get selected inthe combobox box .. How to achieve that.... Thanks in Advance Saniaaa

                  H Offline
                  H Offline
                  Hamid Taebi
                  wrote on last edited by
                  #8

                  Do you select an item on treectrl and you want to compare it with item on combobox


                  WhiteSky


                  A 1 Reply Last reply
                  0
                  • H Hamid Taebi

                    Do you select an item on treectrl and you want to compare it with item on combobox


                    WhiteSky


                    A Offline
                    A Offline
                    Anamika2005
                    wrote on last edited by
                    #9

                    Combobox is not having the item which got selected in the treectrl .so my requiremant is that, as the treectrl item get selected or get changed the combobox should show the current path of the item(which got selected on the treectrl) in its editbox.Is it possible..?and How ? God hepls those who hepls themselves .... Thanks in advance Saniaa

                    H 1 Reply Last reply
                    0
                    • A Anamika2005

                      Combobox is not having the item which got selected in the treectrl .so my requiremant is that, as the treectrl item get selected or get changed the combobox should show the current path of the item(which got selected on the treectrl) in its editbox.Is it possible..?and How ? God hepls those who hepls themselves .... Thanks in advance Saniaa

                      H Offline
                      H Offline
                      Hamid Taebi
                      wrote on last edited by
                      #10

                      You select an item on treectrl and now you want to display this item on ComboBox(edit),Right?


                      WhiteSky


                      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