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 Create Radio buttons dynamically

How to Create Radio buttons dynamically

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestionlounge
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.
  • Z Offline
    Z Offline
    zhaopi
    wrote on last edited by
    #1

    This should be a general question like " how to create dialog item dynamically?" but since i am currently working with radio buttons, i choose to make specific. The context that i am in is that i have defined a combo box with different types of information, and the combo box selection is dynamically calculated. For example, if "name" is selected, i need to draw an edit control beside the combo box.while if "sick?" is selected, two radio buttons are required to answer yes or no. I hope i have explained it clearly. Can anybody help me to solve this problem? Any help will be greatly appreciated.

    C 1 Reply Last reply
    0
    • Z zhaopi

      This should be a general question like " how to create dialog item dynamically?" but since i am currently working with radio buttons, i choose to make specific. The context that i am in is that i have defined a combo box with different types of information, and the combo box selection is dynamically calculated. For example, if "name" is selected, i need to draw an edit control beside the combo box.while if "sick?" is selected, two radio buttons are required to answer yes or no. I hope i have explained it clearly. Can anybody help me to solve this problem? Any help will be greatly appreciated.

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

      If you know how many radio buttons will be needed, why not put them on the form, and show/hide them with ShowWindow ? Otherwise, you can create a new RadioButton using it's constructor. Christian Graus - Microsoft MVP - C++

      Z D 2 Replies Last reply
      0
      • C Christian Graus

        If you know how many radio buttons will be needed, why not put them on the form, and show/hide them with ShowWindow ? Otherwise, you can create a new RadioButton using it's constructor. Christian Graus - Microsoft MVP - C++

        Z Offline
        Z Offline
        zhaopi
        wrote on last edited by
        #3

        Thanks... I have considered the idea of hiding, but it may not be suitable for this problem since the combo box will have a lot of types that require large number of radio buttons or check boxes. Anyway, i will try the hiding method first. Thanks again~ By the way, do you know how to set cursor position in an Edit control? I tried using setsel() function, but nothing appears...

        C 1 Reply Last reply
        0
        • Z zhaopi

          Thanks... I have considered the idea of hiding, but it may not be suitable for this problem since the combo box will have a lot of types that require large number of radio buttons or check boxes. Anyway, i will try the hiding method first. Thanks again~ By the way, do you know how to set cursor position in an Edit control? I tried using setsel() function, but nothing appears...

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

          You need to have the number of characters before you can set the position ( i.e. if the edit box is empty, then the cursor has nowhere to go ). I'm pretty sure that setsel is the way to go. Christian Graus - Microsoft MVP - C++

          Z 1 Reply Last reply
          0
          • C Christian Graus

            You need to have the number of characters before you can set the position ( i.e. if the edit box is empty, then the cursor has nowhere to go ). I'm pretty sure that setsel is the way to go. Christian Graus - Microsoft MVP - C++

            Z Offline
            Z Offline
            zhaopi
            wrote on last edited by
            #5

            About the original topic again... if i use showwindow(),how can i hide them later? and for Edit control, which method should be used to hide them~

            Z 1 Reply Last reply
            0
            • Z zhaopi

              About the original topic again... if i use showwindow(),how can i hide them later? and for Edit control, which method should be used to hide them~

              Z Offline
              Z Offline
              zhaopi
              wrote on last edited by
              #6

              I have found the method already...thanks~

              C 1 Reply Last reply
              0
              • Z zhaopi

                I have found the method already...thanks~

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

                Sorry, I was in a meeting :-) Christian Graus - Microsoft MVP - C++

                1 Reply Last reply
                0
                • C Christian Graus

                  If you know how many radio buttons will be needed, why not put them on the form, and show/hide them with ShowWindow ? Otherwise, you can create a new RadioButton using it's constructor. Christian Graus - Microsoft MVP - C++

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

                  Christian Graus wrote: If you know how many radio buttons will be needed, why not put them on the form, and show/hide them with ShowWindow ? I agree. One of my applications does this, and trying to create/manage the controls at runtime would be a nightmare.


                  "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

                  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