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 get the data from edit control

How to get the data from edit control

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
10 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.
  • V Offline
    V Offline
    vc _fragrance
    wrote on last edited by
    #1

    Hi, I have used the following code to display the text in edit box and a combobox respectively. How can I get the data from these controls. CEdit *Display; Display = reinterpret_cast(GetDlgItem(IDC_EDITCAMPAIGNID)); Display->SetWindowText("tejaswini"); CComboBox *Combo; Combo = reinterpret_cast(GetDlgItem(IDC_COMBOFORMAT)); Combo->SetWindowText("shilpa"); Combo->AddString("Radhika"); Combo->AddString("Lakshmi"); But when i executed the program I am getting only "Lakshmi" in the dropdown list.How can I get "Radhika" also in the drop down list. Can u plz help me. Thanks in advance.

    B P 2 Replies Last reply
    0
    • V vc _fragrance

      Hi, I have used the following code to display the text in edit box and a combobox respectively. How can I get the data from these controls. CEdit *Display; Display = reinterpret_cast(GetDlgItem(IDC_EDITCAMPAIGNID)); Display->SetWindowText("tejaswini"); CComboBox *Combo; Combo = reinterpret_cast(GetDlgItem(IDC_COMBOFORMAT)); Combo->SetWindowText("shilpa"); Combo->AddString("Radhika"); Combo->AddString("Lakshmi"); But when i executed the program I am getting only "Lakshmi" in the dropdown list.How can I get "Radhika" also in the drop down list. Can u plz help me. Thanks in advance.

      B Offline
      B Offline
      Bravoone_2006
      wrote on last edited by
      #2

      GetWindowText

      Bravoone

      _ 1 Reply Last reply
      0
      • B Bravoone_2006

        GetWindowText

        Bravoone

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

        Flaviu_2006 wrote:

        Re: How to get the data from edit control

        or if you have the id of the edit control and no variable associated to it... GetDlgItemText() or use SendMessage() etc...

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

        V 1 Reply Last reply
        0
        • _ _AnsHUMAN_

          Flaviu_2006 wrote:

          Re: How to get the data from edit control

          or if you have the id of the edit control and no variable associated to it... GetDlgItemText() or use SendMessage() etc...

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

          V Offline
          V Offline
          vc _fragrance
          wrote on last edited by
          #4

          ID of the edit control is IDC_EDITCAMPAIGNID Plz can you show the code fot it.

          _ 1 Reply Last reply
          0
          • V vc _fragrance

            Hi, I have used the following code to display the text in edit box and a combobox respectively. How can I get the data from these controls. CEdit *Display; Display = reinterpret_cast(GetDlgItem(IDC_EDITCAMPAIGNID)); Display->SetWindowText("tejaswini"); CComboBox *Combo; Combo = reinterpret_cast(GetDlgItem(IDC_COMBOFORMAT)); Combo->SetWindowText("shilpa"); Combo->AddString("Radhika"); Combo->AddString("Lakshmi"); But when i executed the program I am getting only "Lakshmi" in the dropdown list.How can I get "Radhika" also in the drop down list. Can u plz help me. Thanks in advance.

            P Offline
            P Offline
            prasad_som
            wrote on last edited by
            #5

            tejaswini.g wrote:

            Combo->AddString("Radhika"); Combo->AddString("Lakshmi"); But when i executed the program I am getting only "Lakshmi" in the dropdown list.How can I get "Radhika" also in the drop down list.

            Are you sure, its not getting added?.I dont see any problem with code.

            Prasad Notifier using ATL | Operator new[],delete[][^]

            V 1 Reply Last reply
            0
            • V vc _fragrance

              ID of the edit control is IDC_EDITCAMPAIGNID Plz can you show the code fot it.

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

              tejaswini.g wrote:

              Re: How to get the data from edit control

              char *str=new char[10];
              GetDlgItemText (IDC_EDITCAMPAIGNID,str,10);
              AfxMessageBox (str); // You have the data in str
              delete[] str;
              

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

              V D 2 Replies Last reply
              0
              • P prasad_som

                tejaswini.g wrote:

                Combo->AddString("Radhika"); Combo->AddString("Lakshmi"); But when i executed the program I am getting only "Lakshmi" in the dropdown list.How can I get "Radhika" also in the drop down list.

                Are you sure, its not getting added?.I dont see any problem with code.

                Prasad Notifier using ATL | Operator new[],delete[][^]

                V Offline
                V Offline
                vc _fragrance
                wrote on last edited by
                #7

                Sorry , In the properties I have selected NO integral height now and now I am getting the result. Thank you.

                1 Reply Last reply
                0
                • _ _AnsHUMAN_

                  tejaswini.g wrote:

                  Re: How to get the data from edit control

                  char *str=new char[10];
                  GetDlgItemText (IDC_EDITCAMPAIGNID,str,10);
                  AfxMessageBox (str); // You have the data in str
                  delete[] str;
                  

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

                  V Offline
                  V Offline
                  vc _fragrance
                  wrote on last edited by
                  #8

                  Thank you very much.

                  H 1 Reply Last reply
                  0
                  • _ _AnsHUMAN_

                    tejaswini.g wrote:

                    Re: How to get the data from edit control

                    char *str=new char[10];
                    GetDlgItemText (IDC_EDITCAMPAIGNID,str,10);
                    AfxMessageBox (str); // You have the data in str
                    delete[] str;
                    

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

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

                    _AnShUmAn_ wrote:

                    char *str=new char[10];

                    Why suggest this when CString is preferable? Allocating memory is expensive. Unnecessarily interacting with the memory manager is just asking for trouble. Had you used a CEdit member variable, one line of code would be all that's necessary.


                    "Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.

                    "Judge not by the eye but by the heart." - Native American Proverb

                    1 Reply Last reply
                    0
                    • V vc _fragrance

                      Thank you very much.

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

                      if you have a variable of CEdit you can use from it m_Edit.GetWindowText(...); if you have ID of control you can use GetDlgItemText for text and GetDlgItemInt for number:)

                      _**


                      **_

                      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