[Gambas-user] TableView

ron ronstk at ...239...
Tue Feb 24 12:11:24 CET 2004


On Monday 23 February 2004 22:15, Charlie Reinl wrote:
> Salut,
>
> I would like to use the TableView to work not with a DB-result.
> Something like TV.row[1,1]= "Me" , TV.row[2,1]= "You"
>
> I'm not able to find the way, to show the Data in the grid.
> Can somebody light me the way  ????
>
> I would like it to use it in my Frequest for gdm, so the left outer Column
> can be show as Header, and stay fix on left side.
>
> Amicalement
> Charlie
>

Wel in the Database Manager is a good example to find.

My way using a fixed row count and variable columns count.
the opposit way for fixed columns and variable rows can work the same.

dim tblcols as variant[]
dim tblrows as variant[]
dim col_title as string[]
dim row_title as string[]
dim rowdata as variant[]
dim rowfill as string[]
dim x as integer

tableview.cows.count = desired_rows
tableview.columns.count = desired_columns
tblcols=new variant[]

' fill row_title[] with the titles you want
' fill col_title[] with names you need

' set column header
tableview.Columns = desired_columns
for x = 0 to desired_columns-1
	tableview.columns[x].text = col_title[x]
next

' set row header
for x=0 to desired_rows-1
	tableview.rows[x].text = row_title[x]
next

 'create  cell data for each row in one column
rowfill = new array()
for x = 0 to desired_rows-1
	rowfill.add("") ' so fill it with zero length string
next

' fill master grid
for x=0 to desired_columns-1
	rowdata = new array()
	rowdata = rowfill  'fill it with already preset data
	tblcols.add (rowdata) ' add rowdata for each column
next

' here the tblarr[] contains the row values array so
' tblcols[column_nr][row_nr] gives the cell data back

' for the tableview_data event after the hiding object is removed !
' *************************************************************************
' * !! this one was the missing part, I had empty table after the window 
' * that was hiding the table was moved away.
' *************************************************************************
public sub tableview1_data(row as integer, column as integer)
	' in the database manager the data is taken from the dataabase table
	' by asking the record for row and the field for the column
	' her i now get it from my array grid tblcols[]
	tableview.data.text = tblcols[column][row] 
	' tableview.data.forecolor = tblcolor[column][row]
end

' routine to store and update data
public sub UpdateData( row as integer, column as integer, text as string)
	tblcols[column][row] = text ' this set data for tableview refreshing
	tableview[row,column].data.text = text 'this update screen
end

Ron






More information about the User mailing list