I have used a quick and dirty method via the console to input the number of rows in the grid. I have added 1 to this total so that the rows of actual data displayed is correct.
The columns are of varying widths and these are displayed.
I have added loops to put into the header row to show column numbers and also to display row numbers.
Code: Select all
;produces a grid of textboxes
If OpenConsole()
TotalRows.i = 8
Print ("How many rows of Data? ")
sTotalRows.s = Input()
TotalRows = Val(sTotalRows) +1
EndIf
; Open window
#WindowWidth = 900
#WindowHeight = 550
If OpenWindow(0, 100, 200, #WindowWidth, #WindowHeight, "PureBasic - Grid Demonstration", #PB_Window_MinimizeGadget)
;input "Number of Rows in Table: "; TotalRows
;TotalRows = 8
VisibleRows = 6
vpos = 50 : rowHigh = 20
lDist.i = 30
For row = 1 To TotalRows
For col = 1 To 8
Select col
;First column
Case 1
xpos = lDist : width = 65
;Second Column
Case 2
xpos = lDist+65 : width = 380
;Columns 3 To 8
Case 3,4,5,6,7,8
xpos = lDist+col*65+(445-65*3) : width = 65
EndSelect
gNum.i = row*8-8+col
; NOTE: add 1 to both width and rowHigh and this removes the duplication
; of the border of boxes, resulting in a thinner line.
StringGadget(gNum, xpos, vpos+row*rowHigh-rowHigh, width+1, rowHigh+1, "")
Debug gNum
Next col
Next row
For col = 2 To 8
String.s = "Col " + Str(col-1)
gNum = 1*8-8 + col
SetGadgetText(gNum,String)
Next
; This loop doesn't work. Possibly do Select..Case
For row = 2 To TotalRows
For col =1 To 1
String = "Row " + Str(row-1)
gNum = row*8-8 + col
SetGadgetText(gNum,String)
Next
Next
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Debug "Event fired on Gadget : " + Str(EventGadget())
EndSelect
Until Event = #PB_Event_CloseWindow Or Quit = #True
EndIf
1. Make the row header and the row references Read-Only.
2. Colour the header row and the left hand column.
3. Enter data into the other data cells.
I'm a bit busy now, so progress is slow, but I hope that anyone interested in this little exercise will bear with me.