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. List Control updates

List Control updates

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++tutorialannouncement
10 Posts 4 Posters 1 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
    jagannathan thiruvengadathan
    wrote on last edited by
    #1

    Hai, Greetings of the day!. My doubt is how to update the data's present in the Listcontrol. I am having a List control in VC++ dialog based application, populated with some datas. As soon as i get a new data, the old data has to be updated with new one. Is there any way to solve to my problem. Please help with giving a sample program. Regards Jagan

    R R 2 Replies Last reply
    0
    • J jagannathan thiruvengadathan

      Hai, Greetings of the day!. My doubt is how to update the data's present in the Listcontrol. I am having a List control in VC++ dialog based application, populated with some datas. As soon as i get a new data, the old data has to be updated with new one. Is there any way to solve to my problem. Please help with giving a sample program. Regards Jagan

      R Offline
      R Offline
      Rajesh R Subramanian
      wrote on last edited by
      #2

      Look at CListCtrl::Update and CListCtrl::RedrawItems


      Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா

      J 1 Reply Last reply
      0
      • R Rajesh R Subramanian

        Look at CListCtrl::Update and CListCtrl::RedrawItems


        Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா

        J Offline
        J Offline
        jagannathan thiruvengadathan
        wrote on last edited by
        #3

        Thanks Brahmma. I will try with your suggession and let you know. Regards Jagan

        1 Reply Last reply
        0
        • J jagannathan thiruvengadathan

          Hai, Greetings of the day!. My doubt is how to update the data's present in the Listcontrol. I am having a List control in VC++ dialog based application, populated with some datas. As soon as i get a new data, the old data has to be updated with new one. Is there any way to solve to my problem. Please help with giving a sample program. Regards Jagan

          R Offline
          R Offline
          Ranjoy Guha
          wrote on last edited by
          #4

          First use CListCtrl::DeleteAllItems() then use for(i=0; i < n; i++) CListCtrl::InsertItem(i, 0);//row, column then use for(i=0; i < n; i++) CListCtrl::SetItemText(i, 0, _T("hallo"));//row, column, value string

          R 1 Reply Last reply
          0
          • R Ranjoy Guha

            First use CListCtrl::DeleteAllItems() then use for(i=0; i < n; i++) CListCtrl::InsertItem(i, 0);//row, column then use for(i=0; i < n; i++) CListCtrl::SetItemText(i, 0, _T("hallo"));//row, column, value string

            R Offline
            R Offline
            Rajesh R Subramanian
            wrote on last edited by
            #5

            Ranjoy Guha wrote:

            First use CListCtrl::DeleteAllItems()

            You don't need to delete all items and redraw everything again. This is the worst way of doing it. CListCtrl::InsertItem is enough to insert new items.


            Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா

            R 1 Reply Last reply
            0
            • R Rajesh R Subramanian

              Ranjoy Guha wrote:

              First use CListCtrl::DeleteAllItems()

              You don't need to delete all items and redraw everything again. This is the worst way of doing it. CListCtrl::InsertItem is enough to insert new items.


              Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா

              R Offline
              R Offline
              Ranjoy Guha
              wrote on last edited by
              #6

              Suppose previously there was 15 items later there is 10 items then the previous 5 will stay

              R D 2 Replies Last reply
              0
              • R Ranjoy Guha

                Suppose previously there was 15 items later there is 10 items then the previous 5 will stay

                R Offline
                R Offline
                Rajesh R Subramanian
                wrote on last edited by
                #7

                Ranjoy Guha wrote:

                Suppose previously there was 15 items later there is 10 items then the previous 5 will stay

                I don't understand what you tell. It is simple logic, you don't need to delete everything to add something new and display it.


                Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா

                R 1 Reply Last reply
                0
                • R Rajesh R Subramanian

                  Ranjoy Guha wrote:

                  Suppose previously there was 15 items later there is 10 items then the previous 5 will stay

                  I don't understand what you tell. It is simple logic, you don't need to delete everything to add something new and display it.


                  Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா

                  R Offline
                  R Offline
                  Ranjoy Guha
                  wrote on last edited by
                  #8

                  Suppose There are different Criteria 1. Student: having Properties (Name, Class, Roll, Age) 2 Teacher: having Properties (Name, Degree, Designation) And u need to update them depending on the selected Criteria(Student/Teacher) Now if you dont perform DeleteAllItems then the List Control will keep on growing with each selection. Isn't It ?

                  R 1 Reply Last reply
                  0
                  • R Ranjoy Guha

                    Suppose There are different Criteria 1. Student: having Properties (Name, Class, Roll, Age) 2 Teacher: having Properties (Name, Degree, Designation) And u need to update them depending on the selected Criteria(Student/Teacher) Now if you dont perform DeleteAllItems then the List Control will keep on growing with each selection. Isn't It ?

                    R Offline
                    R Offline
                    Rajesh R Subramanian
                    wrote on last edited by
                    #9

                    The OP asked how to add new data and update the view. Link[^] Now on what grounds do you ask someone to delete all items?


                    Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா

                    1 Reply Last reply
                    0
                    • R Ranjoy Guha

                      Suppose previously there was 15 items later there is 10 items then the previous 5 will stay

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

                      Ranjoy Guha wrote:

                      then the previous 5 will stay

                      This is why DeleteAllItems() should be used. It's the two for loops that you had that were in question. The second one was unnecessary.


                      "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

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

                      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