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. Initialize a List Box

Initialize a List Box

Scheduled Pinned Locked Moved C / C++ / MFC
collaborationhelptutorialquestion
10 Posts 4 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.
  • J Offline
    J Offline
    Jay Hova
    wrote on last edited by
    #1

    Hi, Still trying to get used to programming, and still need a little help. I asked a few questions yesterday about a texteditor, but since have changed my approach. I wanted to know how to initialize a List Box to have text in it everytime the dialog starts up. Is this possible? If it is, is there a way to space out the text that I want to appear? I want it to look like this if possible:

     Team1     Team 2    Team 3    Team 4
    

    Thanks in advance!

    J M 2 Replies Last reply
    0
    • J Jay Hova

      Hi, Still trying to get used to programming, and still need a little help. I asked a few questions yesterday about a texteditor, but since have changed my approach. I wanted to know how to initialize a List Box to have text in it everytime the dialog starts up. Is this possible? If it is, is there a way to space out the text that I want to appear? I want it to look like this if possible:

       Team1     Team 2    Team 3    Team 4
      

      Thanks in advance!

      J Offline
      J Offline
      Jay Hova
      wrote on last edited by
      #2

      Silly me....I got the text to come up.;P Can anyone help with the formatting though? Thanks again

      K D J 3 Replies Last reply
      0
      • J Jay Hova

        Silly me....I got the text to come up.;P Can anyone help with the formatting though? Thanks again

        K Offline
        K Offline
        keegan
        wrote on last edited by
        #3

        what do you mean by 'formatting?' if youre trying to get strings into a listbox, you can use My_List_Box.AddString("hello"); if you mean turning off alphabetical sorting of the contents of the listbox, in the resource editor, witht he listbox selected, look in the properties window and set the 'Sort' value to False (or off, depending). is that what you mean? *.*

        1 Reply Last reply
        0
        • J Jay Hova

          Silly me....I got the text to come up.;P Can anyone help with the formatting though? Thanks again

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

          How you want the data formatted will govern whether you want/need to use a list box, list control, or a grid control. Although it's possible to make a list box look like it has columns, it remains a one-column control that uses tab stops to separate the columns.

          1 Reply Last reply
          0
          • J Jay Hova

            Silly me....I got the text to come up.;P Can anyone help with the formatting though? Thanks again

            J Offline
            J Offline
            Jay Hova
            wrote on last edited by
            #5

            Sorry for not being clear... I would like to have the words spaced out in the line of text. Just so that it is easier to read. I want it so that I do not have to manually hit the space bar between the words that i am gonna enter. Some of the information going on the lines are spaced further in that another like in the chart below. Ideally I want my dialog box to look exactly like this:

                   Team 1      Team 2      Team 3      Team 4
            

            Game 1 80 69
            Game 2 79 70
            Game 3 55 73
            Game 4 73 82

            Player #22 from Team 3 is the MVP of the tournament.
            He lead the team in points, rebounds, assists and steals.
            He also led the tournament in points (33.2), assists (8.9), and steals (3.2)

            I thought about using a list control, but i couldn't get the last 3 sentences to appear across the columns. THANKS IN ADVANCE!!!

            D 1 Reply Last reply
            0
            • J Jay Hova

              Sorry for not being clear... I would like to have the words spaced out in the line of text. Just so that it is easier to read. I want it so that I do not have to manually hit the space bar between the words that i am gonna enter. Some of the information going on the lines are spaced further in that another like in the chart below. Ideally I want my dialog box to look exactly like this:

                     Team 1      Team 2      Team 3      Team 4
              

              Game 1 80 69
              Game 2 79 70
              Game 3 55 73
              Game 4 73 82

              Player #22 from Team 3 is the MVP of the tournament.
              He lead the team in points, rebounds, assists and steals.
              He also led the tournament in points (33.2), assists (8.9), and steals (3.2)

              I thought about using a list control, but i couldn't get the last 3 sentences to appear across the columns. THANKS IN ADVANCE!!!

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

              Use an edit control with a fixed-space font.

              J 1 Reply Last reply
              0
              • D David Crow

                Use an edit control with a fixed-space font.

                J Offline
                J Offline
                Jay Hova
                wrote on last edited by
                #7

                Hi, I am really new to programming, and do not fully understand how to do this. (The fix spaced font) Can you possible give more details on how to do this? Will this get my "table" to look exactly how i want it? Thanks again. Sorry for being slow with this. Mechanical Engineers are not the best programmers! ;P

                D 1 Reply Last reply
                0
                • J Jay Hova

                  Hi, I am really new to programming, and do not fully understand how to do this. (The fix spaced font) Can you possible give more details on how to do this? Will this get my "table" to look exactly how i want it? Thanks again. Sorry for being slow with this. Mechanical Engineers are not the best programmers! ;P

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

                  Just as an example, if you had a dialog box with an edit control, you could put the following in the dialog's OnInitDialog() method: m_font.CreateStockObject(ANSI_FIXED_FONT); m_edit.SetFont(&m_font); Now you just format each line that is added to the edit control.

                  1 Reply Last reply
                  0
                  • J Jay Hova

                    Hi, Still trying to get used to programming, and still need a little help. I asked a few questions yesterday about a texteditor, but since have changed my approach. I wanted to know how to initialize a List Box to have text in it everytime the dialog starts up. Is this possible? If it is, is there a way to space out the text that I want to appear? I want it to look like this if possible:

                     Team1     Team 2    Team 3    Team 4
                    

                    Thanks in advance!

                    M Offline
                    M Offline
                    Mustafa Demirhan
                    wrote on last edited by
                    #9

                    Use CListCtrl instead of CListBox. With the List Control, you can create columns. In your case, you need to create 4 columns and add the data to each column individually... Mustafa Demirhan http://www.macroangel.com Sonork ID 100.9935:zoltrix

                    They say I'm lazy but it takes all my time

                    J 1 Reply Last reply
                    0
                    • M Mustafa Demirhan

                      Use CListCtrl instead of CListBox. With the List Control, you can create columns. In your case, you need to create 4 columns and add the data to each column individually... Mustafa Demirhan http://www.macroangel.com Sonork ID 100.9935:zoltrix

                      They say I'm lazy but it takes all my time

                      J Offline
                      J Offline
                      Jay Hova
                      wrote on last edited by
                      #10

                      Hi, I tried doing that, but is there a way for me to insert the 3 sentences that follow the chart and span them over the columns. I was originally using the list control, but could not find a way to do that. Any help would be appreciated. Thanks in advance

                      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