Dynamically Created Tables on a Scrollarea - random artefacts after scrolling

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

Dynamically Created Tables on a Scrollarea - random artefacts after scrolling

Post by seany »

Hi

So, with my continuing project, I can do this now :

Image

But If I scroll it, sometimes, the location of the last edited cell randomly gets stuck, i.e. does not scroll with the rest of the system.

I have marked a special case with 3 blue arrows, where a copy of the text stay in its position where the cell was before the scrolling happened. In addition, a new copy in the correctly scrolled position also appeared. But note that this copy at the correct location is not always appearing. Sometimes, only the copy in the old place before scrolling remains.

It seems that the Edit controls for tableview often does not work.

None the less, I add my code in attachment.
Any help will be appreciated. Thank you
Attachments
Archiv.zip
(5.28 KiB) Downloaded 85 times
User avatar
BruceSteers
Posts: 1565
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Dynamically Created Tables on a Scrollarea - random artefacts after scrolling

Post by BruceSteers »

Are you using the latest gambas?
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1565
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Dynamically Created Tables on a Scrollarea - random artefacts after scrolling

Post by BruceSteers »

I don't want to sound harsh but your code is pretty bad in places.
from the very first line..
Public parentTable As New TableView(elementTraningForm)
considering parentTable gets used later as..
Public Sub Dyntable_root_ColumnClick(c As Integer)
  parentTable = Last
End
Means using "New" in the declaration is wrong and so is using (elementTrainingForm)
should just be
Public parentTable As TableView
Methods like this...
Public Sub ButtonBox1_Click()
  
  Dim d As Boolean = Dialog.OpenFile()
  Dim c As String = Dialog.Path
  
  PictureBox1.Picture = Picture.Load(c)
  PictureBox1.Mode = PictureBox.Contain
  
  pictureBox1Containes = True
  
  ButtonBox1.Text = c
  pictureViewerForm.imageLocation = c
  
End
if dialog is canceled the function continues to run!
You should use something like this...
Public Sub ButtonBox1_Click()
  
  If Dialog.OpenFile() then Return ' Dialog returns true if canceled so we exit the function.
  Dim c As String = Dialog.Path
  
  PictureBox1.Picture = Picture.Load(c)
  PictureBox1.Mode = PictureBox.Contain
  
  pictureBox1Containes = True
  
  ButtonBox1.Text = c
  pictureViewerForm.imageLocation = c
  
End
As to your layout error i cannot see anything obviously wrong.
I cannot run your code as it's only 3 source files not a testable project.
So it means scrolling through every line of code hunting for a mistake in an unfamiliar code style.

All i can say is ScrollView (you seem to be using a ScrollView not a ScrollArea like the title says) had a glitch like that in an older gambas version but it got fixed.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1565
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Dynamically Created Tables on a Scrollarea - random artefacts after scrolling

Post by BruceSteers »

Maybe try refreshing the tables on scrolling?
Public Sub Dyntable_root_Scroll()

  Last.Refresh

End

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

Re: Dynamically Created Tables on a Scrollarea - random artefacts after scrolling

Post by seany »

Hi

I know the code is bad. It is my first prototype to display AI results.

But yes, i appreciate the corrections I did not know those details. Indeed, the "New TableView" was causing me problems which I circumvented with Variants. But now is better.

I am using 3.17.3 version, and I did test with refresh on scrollview_scroll, but it did not work. I will try with using refresh in table_scroll.
User avatar
BruceSteers
Posts: 1565
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Dynamically Created Tables on a Scrollarea - random artefacts after scrolling

Post by BruceSteers »

seany wrote: Monday 24th October 2022 10:24am Hi

I know the code is bad. It is my first prototype to display AI results.

But yes, i appreciate the corrections I did not know those details. Indeed, the "New TableView" was causing me problems which I circumvented with Variants. But now is better.

I am using 3.17.5 version, and I did test with refresh on scrollview_scroll, but it did not work. I will try with using refresh in table_scroll.
All good fella, we all gotta learn somehow right ? :)

looking at your code it looks like you are making a mistake that i myself used to do a lot.
Because i was not too familiar with properly using Panels and HBox's and their Arrangement properties and Expand or AutoResize properties in containers/controls I was trying to control the layout and positioning myself.

this turns out to be a real pain , baring in mind that your application may look fine as it is on your desktop now but if you try QT not GTK or if you change your desktop theme style then your size calculations might not be right with the new style.

What is better is to REALLY work on making the objects resize/position themselves automatically so you don't have to.
For many objects there is the AutoResize property (works better on some than others)

For TableView you can set
Colums[Index].Width = -1 (does an auto-resize to fit)
Rows[Index].Height = -1 (does an auto-resize to fit row)
Columns[Index].Expand (expands that column)

these methods carefully placed can help with layout.


I don't know why you are doing things like this..
Public Sub Dyntable_Click()
  
  Last.visible = False
  Last.visible = True

if you are having to do something like that to make something work then chances are something else is not right.

A glitch like you have often involves running through the code like a human debugger constantly looking for errors/better ways and eventually you crack it :)
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1565
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Dynamically Created Tables on a Scrollarea - random artefacts after scrolling

Post by BruceSteers »

I got the form to load in a project but all i could make was a bit of a mess ;)

the right hand panel does not fit the buttons.

adding rooms was , er , peculiar to say the least. i got a misplaced tableview at the top.

and if you zoom in on the attached picture you can see where the mouse is there is something there (a tiny little square, it's possibly the initially created parentTable)

It seems you are trying to do something a TableView is maybe not supposed to do?

I did not get the layout glitch you had but i had no text in my fields to go awry
Attachments
Screenshot at 2022-10-24 13-22-30.png
Screenshot at 2022-10-24 13-22-30.png (236.72 KiB) Viewed 1130 times
If at first you don't succeed , try doing something differently.
BruceS
seany
Posts: 32
Joined: Friday 6th December 2019 3:09pm

Re: Dynamically Created Tables on a Scrollarea - random artefacts after scrolling

Post by seany »

The right panel in my case, is adding showing the buttons correctly.

I saw the square. I will check, if that is my problem. Thank you
User avatar
cogier
Site Admin
Posts: 1125
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Dynamically Created Tables on a Scrollarea - random artefacts after scrolling

Post by cogier »

When uploading Gambas files to the Forum please use 'Source archive', your program will then run : -

Image
seany
Posts: 32
Joined: Friday 6th December 2019 3:09pm

Re: Dynamically Created Tables on a Scrollarea - random artefacts after scrolling

Post by seany »

Oh this is very nice, thank you
Post Reply