Recent

Author Topic: TreeView Refresh  (Read 5340 times)

BIT

  • Full Member
  • ***
  • Posts: 119
TreeView Refresh
« on: September 17, 2021, 06:15:11 pm »
Hello! I have a problem again)
I fill the TreeView dynamic with folders and files, then I select the intem, but if the intem is at the end of the TreeView, it is not displayed. Clicking on any component in the form immediately shows the contents of the TreeView.

It does not help:

TreeView1.Refresh;
TreeView1.Update;
TreeView1.Repaint;
« Last Edit: September 17, 2021, 06:18:25 pm by BIT »

jamie

  • Hero Member
  • *****
  • Posts: 4928
Re: TreeView Refresh
« Reply #1 on: September 17, 2021, 11:38:11 pm »
OS, TARGET?
The only true wisdom is knowing you know nothing

BIT

  • Full Member
  • ***
  • Posts: 119
Re: TreeView Refresh
« Reply #2 on: September 18, 2021, 04:40:31 am »

BIT

  • Full Member
  • ***
  • Posts: 119
Re: TreeView Refresh
« Reply #3 on: September 18, 2021, 03:02:02 pm »
I get the index from the INI file, it selects perfectly! But if the index is closer to -1, the TreeView is not drawn until you click on the form elements.

Code: Pascal  [Select][+][-]
  1.    Form1.TreeView1.Select(Form1.TreeView1.Items[IniF.ReadInteger('TreeViewSelected', 'Selected', Form1.TreeView1.Selected.Index)]);  

I can't understand why this is happening (
« Last Edit: September 18, 2021, 03:05:54 pm by BIT »

Awkward

  • Jr. Member
  • **
  • Posts: 95
Re: TreeView Refresh
« Reply #4 on: September 18, 2021, 03:10:50 pm »
looks like Application.ProcessMessages call will not help? btw, how did you made close button for tabs?

BIT

  • Full Member
  • ***
  • Posts: 119
Re: TreeView Refresh
« Reply #5 on: September 18, 2021, 03:14:35 pm »
looks like Application.ProcessMessages call will not help? btw, how did you made close button for tabs?
https://forum.lazarus.freepascal.org/index.php/topic,56274.0.html

BIT

  • Full Member
  • ***
  • Posts: 119
Re: TreeView Refresh
« Reply #6 on: September 18, 2021, 03:21:11 pm »
looks like Application.ProcessMessages call will not help? btw, how did you made close button for tabs?
Did not help  Application.ProcessMessages;

dsiders

  • Hero Member
  • *****
  • Posts: 520
Re: TreeView Refresh
« Reply #7 on: September 18, 2021, 05:33:57 pm »
looks like Application.ProcessMessages call will not help? btw, how did you made close button for tabs?
https://forum.lazarus.freepascal.org/index.php/topic,56274.0.html

I use the tab control from the JVCL package. It draws and handles close buttons.
Lazarus 2.0.12, 2.2.0-RC1, 2.3.0 (Git) / FPC 3.2.0, 3.2.2 / x86-win64 / Windows 8.1

jamie

  • Hero Member
  • *****
  • Posts: 4928
Re: TreeView Refresh
« Reply #8 on: September 18, 2021, 05:49:18 pm »
if you wave the mouse over the area that needs updating does it appear after that ?
The only true wisdom is knowing you know nothing

BIT

  • Full Member
  • ***
  • Posts: 119
Re: TreeView Refresh
« Reply #9 on: September 18, 2021, 06:05:09 pm »
if you wave the mouse over the area that needs updating does it appear after that ?
No, it does not appear if you click on any element on the form that has an event, then the TreeView is drawn.
At the moment, I solved the problem like this, added 1 item to Items through the property, before filling in the data I do TreeView1.Items.Clear; And everything starts to work)

BIT

  • Full Member
  • ***
  • Posts: 119
Re: TreeView Refresh
« Reply #10 on: September 18, 2021, 06:22:04 pm »
if you wave the mouse over the area that needs updating does it appear after that ?
Perhaps the problem is that I am passing LoadFileTreeViewPath (Form1.TreeView1);
and populate it in another unit.
PS: Possibly bad translation I hope you understand.

Awkward

  • Jr. Member
  • **
  • Posts: 95
Re: TreeView Refresh
« Reply #11 on: September 18, 2021, 06:24:41 pm »
btw, i hope, you have paired BeginUpdate/EndUpdate for TreeView?

BIT

  • Full Member
  • ***
  • Posts: 119
Re: TreeView Refresh
« Reply #12 on: September 18, 2021, 06:45:01 pm »
btw, i hope, you have paired BeginUpdate/EndUpdate for TreeView?
I initially tried this method, it did not help.

jamie

  • Hero Member
  • *****
  • Posts: 4928
Re: TreeView Refresh
« Reply #13 on: September 18, 2021, 07:09:11 pm »
if you wave the mouse over the area that needs updating does it appear after that ?
Perhaps the problem is that I am passing LoadFileTreeViewPath (Form1.TreeView1);
and populate it in another unit.
PS: Possibly bad translation I hope you understand.

Change the focus via code to another control and back again...

MyOtherControl.SetFocus;
Application.ProcessMessages;
MyTreeview.SetFocus;

The only true wisdom is knowing you know nothing

wp

  • Hero Member
  • *****
  • Posts: 8906
Re: TreeView Refresh
« Reply #14 on: September 18, 2021, 07:11:44 pm »
It would be helpful if you'd extract the critical part into a separate compilable project which you can upload here.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

 

TinyPortal © 2005-2018