Author |
Topic: Data Grid with Specified Column Widths (Read 3382 times) |
|
joker
Global Moderator
member is offline


Gender: 
Posts: 157
|
 |
Re: Data Grid with Specified Column Widths
« Reply #34 on: Nov 2nd, 2015, 6:24pm » |
|
I'm finding it very klunky saving data out of the grid "boxes" if there's more than a few columns.
Let me clarify, "saving data." I'm saving each row of the grid as a record in a random access file. In one case, I have 20 columns with multiple combo and text boxes.
I was originally wanting to make use of the "handle;row;col" format, but what I try gets tied up with the type of box to be read from. Then there is still the, basically manual, way of mapping to the file field variables.
A magic wand to change the data into field variables is really what I would like to see. Since I'm wishing, it would be nice to allow field variables to be array variables.
EDIT: What I am doing now is transferring data from the grid to an array and resolving any data issues in the process. Then I transfer the array to the records of the RAF since there are only string values to transfer by then. However, it is still klunky.
|
| « Last Edit: Nov 2nd, 2015, 7:34pm by joker » |
Logged
|
|
|
|
joker
Global Moderator
member is offline


Gender: 
Posts: 157
|
 |
Re: Data Grid with Specified Column Widths
« Reply #35 on: Nov 2nd, 2015, 7:10pm » |
|
Single digit row and columns. I read it in another post, but I've never thought there to be a problem. http://lbb.conforums.com/index.cgi?board=extensions&action=display&num=1427217832
I never put any limits on the grid's number of rows or columns so the maphandle function that creates a new "box" handle is certainly using more than a single digit for the row and column part.
I've never seen any problem with doing that, but then I read the above post.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Data Grid with Specified Column Widths
« Reply #36 on: Nov 2nd, 2015, 7:53pm » |
|
on Nov 2nd, 2015, 6:24pm, pnlawrence wrote:| what I try gets tied up with the type of box to be read from. |
|
Are you referring to the need to use !CONTENTS? var$ for the text boxes and SELECTION? var$ for the comboboxes? In that case you could create a 2D string array, indexed by row and column, containing the correct command for each control. Most conveniently you could store the command in the array when you originally declare the controls:
Code: case 0
stylebits #gridWnd.cell, 0, _WS_BORDER,0,0 ' trying to make textbox border look like combobox border
textbox #gridWnd.cell, leftMargin+cumColumnWidth, cellMargin+cumRowHeight, columnWidth(col)+1, rowHeight+1
maphandle #gridWnd.cell, "#gridWnd.cell";row;col
Command$(row,col) = "!CONTENTS? "
case 1
' COMBOBOX doesn't recognize rowHeight. Height is determined from font size. rowHeight doesn't seem to have any effect.
combobox #gridWnd.cell, comboArray1$(), [selectionGridCombo1], leftMargin+cumColumnWidth, cellMargin+cumRowHeight, columnWidth(col)+1, rowHeight
maphandle #gridWnd.cell, "#gridWnd.cell";row;col
Command$(row,col) = "SELECTION? "
Then, when you want to read the contents back, you simply need to do:
Code: for row = 1 to numberOfRows
for col = 1 to numberOfColumns
handle$ = "#gridWnd.cell";row;col
#handle$ Command$(row,col);"var$"
' do something with var$
next col
next row Or have I, once again, misunderstood?
Quote:| Since I'm wishing, it would be nice to allow field variables to be array variables. |
|
It would be fairly easy to support that, I will add it to the wish list. In fact I think you can successfully use numeric array variables in LBB now, but not string array variables.
Richard.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Data Grid with Specified Column Widths
« Reply #37 on: Nov 2nd, 2015, 8:59pm » |
|
on Nov 2nd, 2015, 7:10pm, pnlawrence wrote:| I've never seen any problem with doing that, but then I read the above post. |
|
The problem arises in a situation such as the following. Suppose the row number is 1 and the column number is 10; if you simply concatenate them you would get a handle like #w.box110. Now suppose the row number is 11 and the column number is zero; what handle do you get? It's #w.box110 again!
Of course that doesn't mean you can't use more than 10 rows or columns, but it does mean you have to be more careful with the way you construct the handle variables, for example you could ensure that both row and column are always two-digit numbers. Then the first example would be #w.box0110 and the second example would be #w.box1100.
It may be that in your particular case a conflict never arises, but it might if you enlarged your grid.
Richard.
|
|
|
|
joker
Global Moderator
member is offline


Gender: 
Posts: 157
|
 |
Re: Data Grid with Specified Column Widths
« Reply #38 on: Nov 2nd, 2015, 9:15pm » |
|
Quote:| for example you could ensure that both row and column are always two-digit numbers. |
|
Got it! Don't know why I didn't think that through. (Guess I'm on the Richard Russell BASIC Welfare Program! )
|
|
Logged
|
|
|
|
joker
Global Moderator
member is offline


Gender: 
Posts: 157
|
 |
Re: Data Grid with Specified Column Widths
« Reply #39 on: Nov 2nd, 2015, 9:28pm » |
|
Quote:| Or have I, once again, misunderstood? |
|
You have "stood" it just right. I didn't imagine to store the command in the array, too. That would simplify one part of the FOR/NEXT loop, but I'm not sure that is overall more simple, though.
That's one of those "six one way; half a dozen the other way" situations. Food for thought. Thanks!
On using arrays as RAF field variables, I haven't thought out exactly how that would make it better for me, but thinking there's an advantage in my case. I'm going from GRID -> ARRAY -> FIELD now. It just seems that if the array was the field, then there would be some savings.
I have to constantly remind myself that I am a NOVICE PROGRAMMER with LBB and LB.
|
|
Logged
|
|
|
|
|