WinFBE 2.0.0 - ListView Question

Started by SeaVipe, December 09, 2019, 12:44:24 PM

Previous topic - Next topic

SeaVipe

Hi Paul,
Does the ListView control allow updates to the contents of an item or subitem? I know that direct edit is not yet supported so I edit the contents of a populated ListView in a separate form. Any attempts to write code that updates the control result in a compiler error 7. Expecting ')'.

Clive Richey

Paul Squires

This should work although I have noticed that I did not build a refresh into the Text property, so after assigning your text you should do something like this:

   frmMain.ListView1.Item(3).Text = "New Text"
   frmMain.ListView1.Item(3).SubItem(1).Text = "New SubItem Text"
   frmMain.ListView1.Refresh

I will add the Refresh to the property so after the next update you won't have to manually do the Refresh.
Not sure why you're seeing a compiler error. Can you show me a code snippet of how you are updating the cell's text?
Paul Squires
PlanetSquires Software

Paul Squires

Quote from: SeaVipe on December 09, 2019, 12:44:24 PM
Hi Paul,
Does the ListView control allow updates to the contents of an item or subitem? I know that direct edit is not yet supported so I edit the contents of a populated ListView in a separate form. Any attempts to write code that updates the control result in a compiler error 7. Expecting ')'.



Maybe you are doing SubItems(1) instead of SubItem(1) to reference a cell? That would throw the compiler error.
Paul Squires
PlanetSquires Software

SeaVipe

Hi Paul, Yes! Thanks. SubItems was the problem. But I had been switching back and forth between SubItem and SubItems and still getting the same error. Solved with a reboot. Also, REFRESH is working.
Clive Richey

SeaVipe

#4
Hi Paul, what are the criteria for displaying characters in a ListView? If I exceed the width of the SubItem the end of the line displays an ellipse. If the line contains far too much data then the entire line is just a few ascii chrs.
Problem solved. I'll just put enough info to force the overflow ellipses to appear on the end of the SubItem.
Clive Richey

raymw

The image below is from my listview testing. The left hand column is a single listview of the whole file, and the right-hand listview is the result of parsing the file, about 100 lines at a time, as needed. This saves considerable time compared to parsing the whole file in one hit for larger files. Now, I can select a line in the G-code (lh) column, and I would like the rh list view to align to that. Currently it starts with that selected line at the top of the rh list view. I want to keep the whole file as in lh column, so that I can quickly scroll around the whole file. I will also want it to work the other way around, i.e. select a row in the rh view, and align the gcode view to that. Selections will be visually, e.g. by scrolling and clicking, or by entering a line number, which may be well beyond the displayed area. Thanks to Paul and Jose, the following          ListView_EnsureVisible(formlist.fileview.hwindow  ,startline,TRUE)
   ListView_EnsureVisible(formlist.fileview.hwindow  ,posn +displaylines-1,TRUE)
   formlist.fileview.selectedindex=startline   
              formlist.fileview.refresh

almost does part of it, it ensures the selected gcode is visible, but the selected line can appear anywhere in the displayed lines. It would help if I could find something like viewport topline/viewport bottomline, to give the line numbers of the top and bottom lines of the displayed file code.  e.g, first file line number = 0, last file line number = 20000, selected line = 350, viewport topline = 345,viewport bottomline= 358, say.  Any suggestions gratefully received.

raymw

why does this crash the program? it compiles fine, I've tried many variations, but this one column list view does not want to play. A similar multi-column works fine. Something obvious I guess, but I can't see it. variables like startline, m, etc are defined (in any case, if they were undefined, there would be compiler errors)          startline=0
           formlist.fileview.selectedindex=0
           formlist.fileview.beginupdate
            formlist.fileview.items.clear()
           
           for j as long =  0 to displaylines
           
                  formlist.fileview.item(j).subitems.add("")
                 
           next j       
           
           for j as long =0 to displaylines
                  m=j+startline
                  formlist.fileview.item(j).text= "try"
               
           next j
                    formlist.fileview.endupdate
               formlist.fileview.selectedindex=0
               formlist.fileview.refresh



SeaVipe



Hi Ray, Is the number of Items in the existing 'fileview' ListView <= to 'displaylines' ?
In my test ListView if I try to modify the .Text of a non-existent Item the program crashes. I test with ListView1.Items.Count to ensure there are enough Items to modify.

Clive Richey

raymw

Hi Clive, thanks for your reply. The code I showed is more or less the change to the previous query of mine, in an attempt to get the two listviews in synch. (if you look carefully at the previous posted image, you can see the two scroll bar grab points? are different lengths - the shorter it is, the longer the list. list lengths, displaylines, etc.are the same values for both the multi-column list and the single column list in this version that fails. I was trying, instead of getting the selected items to line up across different length list views, to make both listviews the same length, so that at least selected items would line up. (this was just a test of the listview for inclusion in the ff converted program I've mentioned before). Compiling of that larger program takes a while, so I stripped out the bit I wanted to test. I have come to the conclusion that I was hitting similar problems that I've  had before, a few versions back of winfbe, i.e. it gives the appearance that some indeterminate errors begin to occur, if some settings are made incorrectly, and it appears that they are carried over to future compiles.

I've gone back to altering the original larger version, and the two viewlists work fine together, so for now I've left that particular  problem, and carrying on with the manual translation of the firefly code.