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. changing the cursor postion in a editable combobox???

changing the cursor postion in a editable combobox???

Scheduled Pinned Locked Moved C / C++ / MFC
databasehelpquestion
12 Posts 6 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
    SnaKeBeD
    wrote on last edited by
    #1

    hi everyone, i have a problem, i'm using a editable combo box inmy project and also i have added an event to combobox that when a user keys in any data it will check for the data i the database,if the data is there the data will be listing in the combobox. My problem is after updating the combobox the cursor postion will be at the start(like "|100").I need the cursor should be postioned in the last of line. please reply with some samples or links,please...

    ||SnAkeBed||

    D 1 Reply Last reply
    0
    • S SnaKeBeD

      hi everyone, i have a problem, i'm using a editable combo box inmy project and also i have added an event to combobox that when a user keys in any data it will check for the data i the database,if the data is there the data will be listing in the combobox. My problem is after updating the combobox the cursor postion will be at the start(like "|100").I need the cursor should be postioned in the last of line. please reply with some samples or links,please...

      ||SnAkeBed||

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

      Asuming m_Combo1 is the variable of class CComboBox try int tLen = m_Combo1.GetLBTextLen(m_Combo1.GetCurSel()); m_Combo1.SetEditSel(tLen,tLen); I hope it helps

      D S 2 Replies Last reply
      0
      • D DoomedOne

        Asuming m_Combo1 is the variable of class CComboBox try int tLen = m_Combo1.GetLBTextLen(m_Combo1.GetCurSel()); m_Combo1.SetEditSel(tLen,tLen); I hope it helps

        D Offline
        D Offline
        Deepu Antony
        wrote on last edited by
        #3

        thankyou for kind reply, But it was not working...

        1 Reply Last reply
        0
        • D DoomedOne

          Asuming m_Combo1 is the variable of class CComboBox try int tLen = m_Combo1.GetLBTextLen(m_Combo1.GetCurSel()); m_Combo1.SetEditSel(tLen,tLen); I hope it helps

          S Offline
          S Offline
          SnaKeBeD
          wrote on last edited by
          #4

          thankyou for kind reply, But it was not working...

          ||SnAkeBed||

          D D 2 Replies Last reply
          0
          • S SnaKeBeD

            thankyou for kind reply, But it was not working...

            ||SnAkeBed||

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            SnaKeBeD wrote:

            But it was not working...

            Which means what?


            "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            1 Reply Last reply
            0
            • S SnaKeBeD

              thankyou for kind reply, But it was not working...

              ||SnAkeBed||

              D Offline
              D Offline
              DoomedOne
              wrote on last edited by
              #6

              try this, it work for me. In a MFC dialog app , add a ComboBox, add a control variable m_Combo1 for it. in the CBN_EDITCHANGE message map the metod: OnCombo1EditChange In the body copy the folowing code void CMFC1Dlg::OnCombo1EditChange() { // Here you should do or call the process to look for text on the DB // and modify the ComboBox item list and text //for this examle //Here I get the text entered and compare it whit a fixed text "New" //If the user entered "New" and not exists the item "New Element" in //the combo list, I add de element //then select the "New Element" item as the current selected item // Set the cursor at the end of the element // // For a real use, I think, is better select the text since the // last entered character to the end of the text // CString UserText; TCHAR AddText[12] = _T("New Element"); CWnd * pEdit = m_Combo1.GetWindow( GW_CHILD ); ASSERT( pEdit ); pEdit->GetWindowText(UserText); if ( UserText.Compare(_T("New"))==0) { if (m_Combo1.FindString(-1,&AddText[0])==CB_ERR ) { m_Combo1.AddString(&AddText[0]); m_Combo1.SetCurSel(m_Combo1.FindString(-1,&AddText[0])); } int tLen = m_Combo1.GetLBTextLen(m_Combo1.GetCurSel()); m_Combo1.SetEditSel(tLen,tLen); } } //Note CMFC1Dlg is the class for the dialog Or take a look at: http://www.codeproject.com/combobox/combocompletion.asp

              C S 2 Replies Last reply
              0
              • D DoomedOne

                try this, it work for me. In a MFC dialog app , add a ComboBox, add a control variable m_Combo1 for it. in the CBN_EDITCHANGE message map the metod: OnCombo1EditChange In the body copy the folowing code void CMFC1Dlg::OnCombo1EditChange() { // Here you should do or call the process to look for text on the DB // and modify the ComboBox item list and text //for this examle //Here I get the text entered and compare it whit a fixed text "New" //If the user entered "New" and not exists the item "New Element" in //the combo list, I add de element //then select the "New Element" item as the current selected item // Set the cursor at the end of the element // // For a real use, I think, is better select the text since the // last entered character to the end of the text // CString UserText; TCHAR AddText[12] = _T("New Element"); CWnd * pEdit = m_Combo1.GetWindow( GW_CHILD ); ASSERT( pEdit ); pEdit->GetWindowText(UserText); if ( UserText.Compare(_T("New"))==0) { if (m_Combo1.FindString(-1,&AddText[0])==CB_ERR ) { m_Combo1.AddString(&AddText[0]); m_Combo1.SetCurSel(m_Combo1.FindString(-1,&AddText[0])); } int tLen = m_Combo1.GetLBTextLen(m_Combo1.GetCurSel()); m_Combo1.SetEditSel(tLen,tLen); } } //Note CMFC1Dlg is the class for the dialog Or take a look at: http://www.codeproject.com/combobox/combocompletion.asp

                C Offline
                C Offline
                chandu004
                wrote on last edited by
                #7

                thanks for your post, this may be useful for me in future. BTW, can you suggest me some technique in code project such that i can mark my favourites (like that of yours) such that i can refer them in future? thank you.

                N 1 Reply Last reply
                0
                • C chandu004

                  thanks for your post, this may be useful for me in future. BTW, can you suggest me some technique in code project such that i can mark my favourites (like that of yours) such that i can refer them in future? thank you.

                  N Offline
                  N Offline
                  Nelek
                  wrote on last edited by
                  #8

                  What about the permalink (4th place "reply" and so on)

                  Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson

                  C 1 Reply Last reply
                  0
                  • D DoomedOne

                    try this, it work for me. In a MFC dialog app , add a ComboBox, add a control variable m_Combo1 for it. in the CBN_EDITCHANGE message map the metod: OnCombo1EditChange In the body copy the folowing code void CMFC1Dlg::OnCombo1EditChange() { // Here you should do or call the process to look for text on the DB // and modify the ComboBox item list and text //for this examle //Here I get the text entered and compare it whit a fixed text "New" //If the user entered "New" and not exists the item "New Element" in //the combo list, I add de element //then select the "New Element" item as the current selected item // Set the cursor at the end of the element // // For a real use, I think, is better select the text since the // last entered character to the end of the text // CString UserText; TCHAR AddText[12] = _T("New Element"); CWnd * pEdit = m_Combo1.GetWindow( GW_CHILD ); ASSERT( pEdit ); pEdit->GetWindowText(UserText); if ( UserText.Compare(_T("New"))==0) { if (m_Combo1.FindString(-1,&AddText[0])==CB_ERR ) { m_Combo1.AddString(&AddText[0]); m_Combo1.SetCurSel(m_Combo1.FindString(-1,&AddText[0])); } int tLen = m_Combo1.GetLBTextLen(m_Combo1.GetCurSel()); m_Combo1.SetEditSel(tLen,tLen); } } //Note CMFC1Dlg is the class for the dialog Or take a look at: http://www.codeproject.com/combobox/combocompletion.asp

                    S Offline
                    S Offline
                    SnaKeBeD
                    wrote on last edited by
                    #9

                    hi thankyou for sending the code , your piece of code is working fine when i tried as seperate program i'm sending the piece of code where i have to change the cursor postion. Since i have to Reset the condent of the combobox for the previous value, can u tell me tsome way to sort it out???? void CBillingDlg::OnEditchangeProductID() { int vv=m_ProductID.GetCoun();//m_ProductID //is my variable for combo box CString var; CString xx; m_ProductID.GetWindowText(var);//getting text// xx=var; var=var+'%'; m_ProductID.ResetContent();//Foe clearing the previous values// m_ProductID.SetWindowText(xx); /*Below Code for accessing the database*/ CString query; query.Format("Select ProductID from Product where ProductID like '%s%%'",var); TCHAR sz[1024]; sprintf(sz, query); char *ptr=sz; bas obj; spring++; int i=obj.ProductName(ptr,"ProductID"); for(int peek = 0;peek||SnAkeBed||

                    D 1 Reply Last reply
                    0
                    • S SnaKeBeD

                      hi thankyou for sending the code , your piece of code is working fine when i tried as seperate program i'm sending the piece of code where i have to change the cursor postion. Since i have to Reset the condent of the combobox for the previous value, can u tell me tsome way to sort it out???? void CBillingDlg::OnEditchangeProductID() { int vv=m_ProductID.GetCoun();//m_ProductID //is my variable for combo box CString var; CString xx; m_ProductID.GetWindowText(var);//getting text// xx=var; var=var+'%'; m_ProductID.ResetContent();//Foe clearing the previous values// m_ProductID.SetWindowText(xx); /*Below Code for accessing the database*/ CString query; query.Format("Select ProductID from Product where ProductID like '%s%%'",var); TCHAR sz[1024]; sprintf(sz, query); char *ptr=sz; bas obj; spring++; int i=obj.ProductName(ptr,"ProductID"); for(int peek = 0;peek||SnAkeBed||

                      D Offline
                      D Offline
                      DoomedOne
                      wrote on last edited by
                      #10

                      The easy way set the sorted property of the ComboBox to true, if the sort order is defined by the text in the list. If not the easiest way is to add an “Order by” in the Query. Assuming the Data source supports it (i.e. Any ANSI SQL DB), and the ordering key is accessible in the query. If the order needed is not defined by the data returned or accessed in the query you need to sort it manually, i.e. loading it into a vector or array, ordering the array with any sorting method (bobble, fast sort, hash tables ...) Then insert the values from the ordered array.

                      1 Reply Last reply
                      0
                      • N Nelek

                        What about the permalink (4th place "reply" and so on)

                        Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson

                        C Offline
                        C Offline
                        chandu004
                        wrote on last edited by
                        #11

                        thanks for your reply, but will the permalink adds the post to my favourites? what i mean is, i should be able to see my favourites from any system. can you suggest in this regard? and replying tthe interested post and finding them in my posts from my profile page will also do. but i would have to reply them saying "thank you and your post is useful for me in future" which occupies unnecessary space in CP and this may also be in convinient to some members. thank you.

                        N 1 Reply Last reply
                        0
                        • C chandu004

                          thanks for your reply, but will the permalink adds the post to my favourites? what i mean is, i should be able to see my favourites from any system. can you suggest in this regard? and replying tthe interested post and finding them in my posts from my profile page will also do. but i would have to reply them saying "thank you and your post is useful for me in future" which occupies unnecessary space in CP and this may also be in convinient to some members. thank you.

                          N Offline
                          N Offline
                          Nelek
                          wrote on last edited by
                          #12

                          Yes, make a try... if you use search for a message, there will be "?" and "search" keywords in the url on the navigator when you go to the selected one. But once you are in the message, if you press "permalink" then the navigator autoupdates itself and in the toolbar you will have an URL in absolute mode with the code ID of the forum and message. So if you add it in favourites or copy paste in a txt you will have the url to the message, although the board grows a lot. I make it that way, take the permalink and then write down a short description in a txt, adding the link at the end. So I have the direction and something that helps me find the one I need.

                          Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson

                          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