Tables - column position

LineCutter

Active Member
Licensed User
Longtime User
I've been redoing the EditableTable.sbp to be more generic (i.e. reading much of the data needed from the table data itself rather than programming it with the table design)...
But (there's always a but!) - if I resize the columns too large (or load a wide table) then the horizontal scroll bar appears. If I use it then my edit-textbox disappears off of the right hand of the screen (offset is vs. left of table, not left of displayed table).
Does anyone know of a way to read the offset of the columns from the left hand edge of the displayed table (or a way to stop resizing, or a way to locate the caret in X&Y coordinates on the form)?
 

Cableguy

Expert
Licensed User
Longtime User
There is a method to get/set the columns Width and height, so estableshing the ofset of the selected cell should be straight foward...
Something like...

Sub Table_SelectionChanged
Textbox1.Left=TB.ColNumber(TB.SelectedCol)*TB.ColWidth(TB.SelectedCol)+1
'Textbox left value = selected Column index * The column Width + 1 to place the TextBox INSIDE the CELL
'The same Aplies to the TOP propertie...

End Sub
 

LineCutter

Active Member
Licensed User
Longtime User
Almost!

Nearly...what you have described is what I've been doing.

Consider the following:
I have a table control 500 pixels wide.
I load a table with 10 columns, each 100 pixels wide.
I scroll horizontally to column 9 & click in the cell to edit it.

If I calculate the left offset of the cell (as 900) then the edit box ends up 400 pixels to the right of the cell, in the area that the cell would have been if my control were 1000 pixels wide.
 

Cableguy

Expert
Licensed User
Longtime User
Please up-Load the code, and I'll try to make some sense of it...
 

LineCutter

Active Member
Licensed User
Longtime User
OK, I present an updated version of the really rather good already EditableTable1.1.
Feed it any table you like, preferably a wide one, & then use the scroll bar to move to the right. Click a cell & see if you can spot the textbox (you could make the form wider if you can't see it at all). Also try activating the textbox & then moving the scroll bar.

I've got a way to go to get this right...:sign0085:
 

Attachments

  • EditableTable1.2.sbp
    2 KB · Views: 214

klaus

Expert
Licensed User
Longtime User
Hi Linecutter
I had a look at your problem and I am afraid that there is no solution at that time for the positionning of the text box.
The problem is that there is information missing:
- the x value from the beginning of the table to the first part of the first displayed column, even the ColWidth value is of no help because the table displays also a partial first column.
- the row number of the first displayed row.
- or the Values of the integrated VScrollBar and HScrollBar of the table.

As long as these values are not available you cannot position your TextBox onto a Cell.

In trying to solve your problem I found a problem with the ColWidth values.
I posted a Bug report:
http://www.b4x.com/forum/showthread.php?p=9746#post9746

Best regards
Klaus
Switzerland
 

klaus

Expert
Licensed User
Longtime User
Hi LineCutter,
After your post in the thread
http://www.b4x.com/forum/showthread.php?t=1777

Klaus: It seems that the scrollbar control available in ControlsEx.dll might be a workaround... if the change in column width can trigger an event so that we know when to add the control, or we accept that it needs to be there all the time & for every table event we bring the scrollbar to the front, hiding the real one if it's being displayed.
Haven't played with it yet, nor thought through the maths - that has to wait until we can tell if the total table (column) width has changed.

I have looked at it and you find joined a first solution. There is still some finetuning to do, espacilly for the device, but it works.

I am not really convinced on an editable Table like this, I prefer having a Panel with all the data for one record set available and editable, but this is just an opinion.

Hope this will help you.

Best regards.
Klaus
Switzerland
 

Attachments

  • EditableTable1.4.zip
    10.2 KB · Views: 215
Top