[Solved for now] How to get the height of the title of a tableview

Post your Gambas programming questions here.
Post Reply
seany
Posts: 32
Joined: Friday 6th December 2019 3:09pm

[Solved for now] How to get the height of the title of a tableview

Post by seany »

Please consider this snippet :
TableView1.Columns.Count = 3
  TableView1.Columns[0].Title = "Variable Class"
  TableView1.Columns[0].Width = TableView1.Font.TextWidth(TableView1.Columns[0].Title) + 10
  TableView1.Columns[1].Text = "ID"
  TableView1.Columns[1].Width = TableView1.Font.TextWidth(TableView1.Columns[1].Title) + 100
  TableView1.Columns[2].Text = "DATA"
  TableView1.Columns[2].Width = TableView1.Font.TextWidth(TableView1.Columns[2].Title) + 200
Now, I have clicked on a table cell. So the current row index is stored in TableView1.Row. I want to know, relative to the container, where the top of the current cell is. So all what I need to do is sum up the individual row heights upto but not including current cell / current row index, then add TableView1.Top. Now, if I do this :
sumVals = 0
  For cnt = 0 To TableView1.Row - 1
    sumVals = sumVals + TableView1.Rows[cnt].Height 
  Next
cellTop = TableView1.Top + sumVals + 2 
This however is not including the height of the title row. In the For loop definition, the 0 jumps to the first row after the title row ( = second overall) and starts counting from there.

I thought of using
TableView1.Current.Top
as well. But in the first data row after the title row ( = second overall) it returns a value of 0, again ignoring the title height.

How can I address the problem, so that the height of the title row is counted? Thank you.
Last edited by seany on Thursday 20th October 2022 1:36pm, edited 1 time in total.
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: How to get the height of the title of a tableview

Post by BruceSteers »

Maybe

TableView1.Columns.Height
If at first you don't succeed , try doing something differently.
BruceS
seany
Posts: 32
Joined: Friday 6th December 2019 3:09pm

Re: How to get the height of the title of a tableview

Post by seany »

That seems to work for now. Thank you
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: [Solved for now] How to get the height of the title of a tableview

Post by BruceSteers »

i think it's the correct thing you asked for, the height of the header.

I probably should not have led with "Maybe" in the last post ;)

http://gambaswiki.org/wiki/comp/gb.qt4/ ... mns/height
If at first you don't succeed , try doing something differently.
BruceS
Post Reply