Is there a way to create a view like a listbox but then rotated 90 ° te the left ? I would like to be able to scroll trough data from a database from left to right in stead of from bottom to top. So the culumns shoud be presented horizontally. Kind like a weekview of a calendar with the date on top and the data below it.
Or do i make a grid with textfields myself ?
Thanks for your edeas !
From the title, I thought you wanted the text rotated 90 degrees but from the verbiage I think you want the text in the normal orientation but have a listbox with as many listbox rows as there are fields in a database table, and as many listbox columns as there are records in the database table. Am I right?
The biggest limitation you may hit is the standard Xojo listbox supports a limited number of columns. At one point that was 64 though I believe it is now 256. Still, 256 columns won’t support more than a very small database.
My suggestion would be to instead use a third-party control called DataView for a few reasons:
- I believe both the row and column count are basically unlimited
- You can “lock” or “freeze” column(s) on the left, say if you wanted the first column to have the field name or description
- You can easily define a “datasource” to dynamically provide the data for visible cells which need to be painted
That last point is crucial to good performance regardless of database size. Essentially, you never populate the listbox cells with actual data. You set the column count based on the number of records in the database (plus 1 or more for field names or descriptions if you like). You set the row count based on the number of fields in the table.
Then based on how many rows and columns can visibly fit, and it will automatically handle the scrollbars for you. For any cell which is visible (or becomes visible due to scrolling) the data view will “call back” to a function you provide which is conceptually similar to the cell text paint routine of a standard listbox. You are told the row and column it needs, and you pass back the data value. For a database, you might take the column number and use in a SQL select statement’s OFFSET value with a LIMIT 1 to read just a single record. Then use the row number to get the Nth field from the recordset.
I believe the DataView demo projects includes a sample SQLite database table browser. You’d want to start with it then reverse all the row and column references to achieve what I think you mean by the “rotated listbox view”. Plus drop the column headings in lieu of an initial column with field names, which you can then “lock” to keep visible.
No vested interest; just a happy customer of the product.
Mac or Windows?
You might be able to do this quickly by embedding Excel as an OLEObject , and populating the columns of that, if you are on Windows.
If no, then a couple of ideas:
Create a container control with a label above a text area.
Embed that on a canvas.
Clone it so that you have as many across the canvas as you need.
Populate them with data.
Then put a scrollbar below, and use the scrollbar to ‘scroll’ the canvas, which will move the containers into view.
For a more ‘jerky’ system, you could implement a ‘lazy load’
Display (say ) 10 such label/text area side by side on screen.
Populate with columns 1…10
Add a scrollbar below
As the scrollbar value changes, repopulate the 10 things , but
<from scrollbar.value to scrollbar.value + 9>
So you only ever have 10 boxes, but what they show varies by what the scrollbar suggests.
You would need to cap the scroll start position when it reached <number of columns - 9>
Thank You both for your interesting reply’s. I think the solution is near