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#
  4. Maximum number of columns for a ListView control

Maximum number of columns for a ListView control

Scheduled Pinned Locked Moved C#
question
8 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.
  • K Offline
    K Offline
    Kalvin Work
    wrote on last edited by
    #1

    I have a Windows.Forms.ListView control. On this control I need to have 310 columns. While scrolling through the listview the first 245 display without problems. After that, the column headers stop scrolling, but the data continues to scroll. Is there a setting somewhere for the max number of column headers that are allowed? Any idea what might be causing this? Thank you. Kalvin

    - Kalvin

    K M D S 4 Replies Last reply
    0
    • K Kalvin Work

      I have a Windows.Forms.ListView control. On this control I need to have 310 columns. While scrolling through the listview the first 245 display without problems. After that, the column headers stop scrolling, but the data continues to scroll. Is there a setting somewhere for the max number of column headers that are allowed? Any idea what might be causing this? Thank you. Kalvin

      - Kalvin

      K Offline
      K Offline
      Kalvin Work
      wrote on last edited by
      #2

      I've learned a little more about what is going on with this. It isn't a problem with the number of columns, but the total width of all the columns. If I give each column a width of 140 then I have a problem scrolling. If I give each column a width of only 100 with 310 columns then there is no problem.

      listView1.View = View.Details;
      listView1.MultiSelect = false;
      listView1.FullRowSelect = true;
      listView1.HideSelection = false;

      for (int i = 0; i < 310; i++)
      {
      listView1.Columns.Add((i-1).ToString(), 140);
      }

      ListViewItem itm = listView1.Items.Add("newRow");
      foreach (ColumnHeader columnHeader in listView1.Columns)
      {
      itm.SubItems.Add(columnHeader.Index.ToString());
      }

      - Kalvin

      M 1 Reply Last reply
      0
      • K Kalvin Work

        I have a Windows.Forms.ListView control. On this control I need to have 310 columns. While scrolling through the listview the first 245 display without problems. After that, the column headers stop scrolling, but the data continues to scroll. Is there a setting somewhere for the max number of column headers that are allowed? Any idea what might be causing this? Thank you. Kalvin

        - Kalvin

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        The docs[^] state "Unexpected behavior can result when the combined width of all columns exceeds 32,768 pixels." Could that be an issue?

        Mark Salsbery :java:

        L 1 Reply Last reply
        0
        • K Kalvin Work

          I've learned a little more about what is going on with this. It isn't a problem with the number of columns, but the total width of all the columns. If I give each column a width of 140 then I have a problem scrolling. If I give each column a width of only 100 with 310 columns then there is no problem.

          listView1.View = View.Details;
          listView1.MultiSelect = false;
          listView1.FullRowSelect = true;
          listView1.HideSelection = false;

          for (int i = 0; i < 310; i++)
          {
          listView1.Columns.Add((i-1).ToString(), 140);
          }

          ListViewItem itm = listView1.Items.Add("newRow");
          foreach (ColumnHeader columnHeader in listView1.Columns)
          {
          itm.SubItems.Add(columnHeader.Index.ToString());
          }

          - Kalvin

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          32768 / 140 is ~234...looks like exceeding 32768 pixels IS a bad idea[^] :)

          Mark Salsbery :java:

          1 Reply Last reply
          0
          • M Mark Salsbery

            The docs[^] state "Unexpected behavior can result when the combined width of all columns exceeds 32,768 pixels." Could that be an issue?

            Mark Salsbery :java:

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            Mark Salsbery wrote:

            Could that be an issue?

            Nope. It could be a paradox: when warned like that, there no longer is anything not to expect. :-D

            Luc Pattyn [My Articles] Nil Volentibus Arduum

            1 Reply Last reply
            0
            • K Kalvin Work

              I have a Windows.Forms.ListView control. On this control I need to have 310 columns. While scrolling through the listview the first 245 display without problems. After that, the column headers stop scrolling, but the data continues to scroll. Is there a setting somewhere for the max number of column headers that are allowed? Any idea what might be causing this? Thank you. Kalvin

              - Kalvin

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

              Your specific problem has been identified, however I would suggest you have a greater problem in the design of the UI part of your application. I cannot imagine any scenario where it would be useful to any user that so many columns are displayed. Better to provide a means for the user to select to dispay differing subsets of the data so they can view what is relevant easily than to swamp them with so much data that requires endless scrolling IMO.

              Dave
              Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
              BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

              D 1 Reply Last reply
              0
              • D DaveyM69

                Your specific problem has been identified, however I would suggest you have a greater problem in the design of the UI part of your application. I cannot imagine any scenario where it would be useful to any user that so many columns are displayed. Better to provide a means for the user to select to dispay differing subsets of the data so they can view what is relevant easily than to swamp them with so much data that requires endless scrolling IMO.

                Dave
                Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
                BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

                D Offline
                D Offline
                Dan Mos
                wrote on last edited by
                #7

                :thumbsup: Very true. I mean displaying hundres of columns is just insane IMHO.

                All the best, Dan

                1 Reply Last reply
                0
                • K Kalvin Work

                  I have a Windows.Forms.ListView control. On this control I need to have 310 columns. While scrolling through the listview the first 245 display without problems. After that, the column headers stop scrolling, but the data continues to scroll. Is there a setting somewhere for the max number of column headers that are allowed? Any idea what might be causing this? Thank you. Kalvin

                  - Kalvin

                  S Offline
                  S Offline
                  SilimSayo
                  wrote on last edited by
                  #8

                  Why would you want to display 310 columns?

                  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