Cyllceaux wrote: Mon May 24, 2021 5:28 pm
Hey cap...
Oh... I see the Problem.
You init the table with 100 rows. Than you add 100 more.
There is a bug at my side... I will fix it.
But... Why do you need a Grid, when you add your own columns? You can use for this a simple table. The grid is for, when you know the size
Doh!
Thanks - makes sense now.
But your grid is waaaay better than a listicongadget, and gives me more flexability going forward.
Code: Select all
Declare SelectCell(canvas,*row.strMyTableCell)
Procedure SelectCell(canvas,*row.strMyTableCell)
Debug MyTableGetTableSelectedRow(canvas)
Debug MyTableGetTableRowHeight(canvas)
Debug MyTableGetCellText(canvas, MyTableGetTableSelectedRow(canvas)-1, 1)
MyTableAutosizeRow(canvas,MyTableGetTableSelectedRow(canvas)-1)
EndProcedure
Global mainWindow=OpenWindow(#PB_Any,0,0,1100,600,"MyTable",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget)
Global canvasGrid=CanvasGadget(#PB_Any, 5, 5, 1000, 500,#PB_Canvas_Container|#PB_Canvas_Border|#PB_Canvas_Keyboard)
Global hscrollGrid=ScrollBarGadget(#PB_Any, 0, 0, 0, 20, 0, 0, 100)
Global vscrollGrid=ScrollBarGadget(#PB_Any, 0, 0, 20, 0, 0, 0, 100,#PB_ScrollBar_Vertical)
CloseGadgetList()
MyTableGridRegister(mainWindow, canvasGrid, hscrollGrid, vscrollGrid, 0, 0, #MYTABLE_TABLE_FLAGS_GRID|#MYTABLE_TABLE_FLAGS_MULTISELECT|#MYTABLE_TABLE_FLAGS_STOP_DRAWING|#MYTABLE_TABLE_FLAGS_ALL_ROW_COUNT);, 0, 1, "canvasgrid")
MyTableAddColumn(canvasgrid,"ID",0,#MYTABLE_COLUMN_FLAGS_RIGHT|#MYTABLE_COLUMN_FLAGS_INTEGER|#MYTABLE_COLUMN_FLAGS_RESIZEABLE)
MyTableAddColumn(canvasgrid,"Firma",0)
MyTableAddColumn(canvasgrid,"Vorname",0)
MyTableAddColumn(canvasgrid,"Nachname",0,#MYTABLE_COLUMN_FLAGS_RESIZEABLE)
MyTableAddColumn(canvasgrid,"GeburtsdatumGeburtsdatum Geburtsdatum Geburtsdatum",0)
MyTableAddColumn(canvasgrid,"Mail",0)
MyTableAddColumn(canvasgrid,"Telefon",0)
For i=1 To 100
MyTableAddRow(canvasgrid, Str(i)+"|Firma "+Str(i)+#CRLF$+"ABC"+"|Vorname "+Str(i)+#CRLF$+"|Nachname "+Str(i)+"|"+FormatDate("%dd.%mm.%yyyy",AddDate(Date(1980,1,1,0,0,0),#PB_Date_Day,i))+"|012345678-"+Str(i)+"|test"+Str(i)+"@test.de")
Next
MyTableRedraw(canvasgrid, #True)
MyTableAutosizeColumn(canvasgrid, #PB_Ignore)
For i=1 To 100
MyTableAutosizeRow(canvasgrid, i-1)
Next
MyTableSetEventRowSelected(canvasgrid, @SelectCell())
Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
MyTableUnRegister(canvasgrid)
A few more questions if i may :
Is there a way to reszize rows to column text for the whole grid ? as you can see from above, i used the MyTableAutosizeRow() method in a loop to acheive the same.
Also, when in use as a simple table, is there a way to click on a cell to select that particular row - just like clicking on the id column ?
Is there a way of returning the no of columns in a grid, I couldn't see a count column method ?
Congrats once again on this piece of work.