Announcement

Collapse
No announcement yet.

ListView with "frozen" column

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ListView with "frozen" column

    For once I have something to contribute and not just pester the rest of you. I ran into a situation where users requested that first column of a listview be "frozen" (freeze) as they can do in Excel. Well I don't have access to Excel's source code, so this is an attempt to recreate the feature:
    PowerBASIC and related source code. Please do not post questions or discussions, just source code.

    The bigger issues I had were:
    1. How to send all the scrolling messages back and forth with no visual delay in scrolling
    2. How to hide the scroll bars for the left-most ListView
    3. How to keep the left-most LV from scrolling horizontally

    Please feel free to offer any tips or crticisms. And I thank all of you for your help.

    I guess it could have a custom scroll bar for the right-most listview that is under both listviews. That would make it look more Excel-ish. But for our purposes, it is good as it currently is.
    Bill Scharf

  • #2
    I didn't view the link yet or dive into this real deep, but off the top of my head a Virtual Listview will be your best bet with this instead of messing around with all the scrolling, etc. When it requests data for the columns/rows you want froze, just always give it the same data while giving new for the rest of the cells.
    sigpic
    Mobile Solutions
    Sys Analyst and Development

    Comment


    • #3
      Someone here posted at least one example of "synchronized scrolling listviews" which is pretty much what you have.

      If you can find that code (I know it's in source code forum) that should give you some ideas.

      Meanwhile, the virtual idea with "lie about what data are at this row/column" is worth looking at; so would be eschewing a virtual style and accomplishing the same thing with drawing the 'frozen' column (or rows) yourself on the WM_NOTIFY/NM_CUSTOMDRAW notification. I know there are demos of WM_NOTIFY/NM_CUSTOMDRAW in Source Code Forum because I put some of them there.

      MCM
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        Thank you for your posts.

        Roger,

        Yes, there are many ways to attack this. You can have it so that the left-most column in view keeps changing. However, that looks really odd, because it will scroll a few pixels or so and then jump. The column is not truly frozen. It will move...it just will always stay visible.

        There is also a method of scrolling other columns into the first column. That means as you scroll, you adjust the width of column #2 down to zero , then column #3 to zero and so on so that column #1 is always visible. This method I find preferrable to the one above. However, you still have issues with the scrollbar shrinking and growing. You also have all the overhead of storing, sizing, restoring, etc the sizes of the columns. In my application the listview can have up to 255 columns and we are trying to trim down the overhead.

        Michael,

        I appreciate your willingness to always help those of us who are less experienced with PB. I did steal some from the parallel listview example (Kev Peel I think posted it), but it had some issues with the way it scrolled, it did not track the scrollbar thumb, and it had a scrollbars that I needed to "hide." It is probably true that what I have is not much more than what Kev posted, but it took me hours to get it from what Kev had to what I have. Now I hope to save others some of that time. I am sure some could do it in 1/2 an hour...but not me
        Bill Scharf

        Comment


        • #5
          Might look into an actual Grid control then like EGrid, etc.
          sigpic
          Mobile Solutions
          Sys Analyst and Development

          Comment


          • #6
            Not to hijack, but I too have been playing around with listview or custom listviews, and wondered if the best idea is to keep the data in array, and just display in the listview? or since all is more or less "Re-Inventing the wheel" if there is a list of grids or listviews or etc that people prefer?

            I have been poking around with some of each, but no one answer is simple enough or cover all what I am thinking about, so I just wondered.


            Hmmmm gives me an idea for a new post...."Concepts you thought were simple but aren't....(or maybe they are and you just are not asking correctly???"
            Engineer's Motto: If it aint broke take it apart and fix it

            "If at 1st you don't succeed... call it version 1.0"

            "Half of Programming is coding"....."The other 90% is DEBUGGING"

            "Document my code????" .... "WHYYY??? do you think they call it CODE? "

            Comment


            • #7
              gridish...maybe

              Roger,

              You have a good point. It is like I am trying to make something look grid-ish.... We went with SIGrid in a previous version of our software and it has left a bad taste in our mouths for 3rd-party grid controls. Therefore one of the requirements from the beginning was to not use any, but instead explore if we could tweak, form, and if need be hammer a listview into doing what we needed. I have seen Elias' Egrid and it looks very impressivbe. I do not recommend SIGrid except for the simplest of uses.

              Cliff,

              The problem with just storing the data in arrays (and I assume displaying it dynamically) is that the column will not really freeze. It will still scroll. You can move the column or data so that the data is always visible, but then you will have a column jumping around as you scroll. I was aiming for something that is solid and frozen. As far as concepts I thought were simple, but were not...I would love to see that one. I would certainly add drag-n-drop multi-column listviews to that. I have still not perfected that yet.
              Bill Scharf

              Comment


              • #8
                Bill I will admit I had to go back and look at the example again.
                (nicely done by the way)

                I have been playing around with several concepts between scrolling, drag n drop, and checkboxes and comboboxes, in a listview or grid-like kind of thing.

                I will have to look deeper, but I can already see a use for why "Frozen" can be a good idea in some cases.

                I too have gone the route of "no 3rd party" because of not being able to customize for my purposes....although I will admit, sometimes a lot better to use 3rd party because they already went through what I am learning, and can do it better than I am trying.

                All in all....nice example Bill
                I look forward to dissecting and understanding each piece and learning from it
                Engineer's Motto: If it aint broke take it apart and fix it

                "If at 1st you don't succeed... call it version 1.0"

                "Half of Programming is coding"....."The other 90% is DEBUGGING"

                "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                Comment


                • #9
                  The more items (rows) in a listview, the longer it takes to load.

                  Going "virtual" basically takes no time to load the initial set of data.

                  Display-wise, its pretty much a wash if you ask me.

                  Used to get pretty crummy speed-wise on my Win/98 machine (400 Mhz, 512 Mb RAM), but even with "lots" of items on this machine (Win/XP pro, 3 Ghz,1 Gb ) it's pretty quick.
                  Michael Mattias
                  Tal Systems (retired)
                  Port Washington WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment


                  • #10
                    Cliff,

                    I know what you mean--I don't want to "reinvent the wheel"; however we had issues with third-party controls that would cause annoyances and even hard crashes. Even when you get the source for the control, it is very time-consuming to step through it to find bugs or tweak it. In this case the decision was made by my bosses, so I did not even explore the third-party options.

                    Michael,

                    Again you have a great point. As the columns and/or rows increase then scrolling will get slower and look worse. I will explore that option as time allows. The goal for me is to also add drag-and-drop to the listview and intergrate it into a module of about 10,000 lines of code

                    I appreciate everybody's comments!
                    Bill Scharf

                    Comment


                    • #11
                      It appears I'm a bit late but......

                      Attached is a frozen column demo using the spreadsheet control designed by Ketil'O.
                      I want to note that I am not advocating the use of free controls over commercial ones,
                      it's just that all the commercial ones that I've seen are way OVERKILL for most of my needs.
                      I have just started experimenting with this control and it appears it may fit most of mine.
                      The hardest part is figuring out how to use it. Not much in the way of documentation but
                      his last set of demos for RadAssembler show a lot more than was avaiable previously.
                      The attached zip includes the dll and PB inc file.

                      For those that mentioned not wanting to use a third party control,note that the source is available.

                      James
                      Attached Files
                      Last edited by jcfuller; 12 Jun 2008, 03:26 PM.

                      Comment


                      • #12
                        thanks!

                        Thanks James! Great Example! I cannot use it for my purposes, but it is a really nice example. I appreciate it.
                        Bill Scharf

                        Comment

                        Working...
                        X