473,666 Members | 2,075 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TreeView doesn't show last item

Hi all,

in my WinForm-Application i have a strange problem with the TreeView
Control.
As you can see in the samplecode below, i fill the TreeView by adding some
nodes with sub nodes. (The subnodes don't matter in the first place.)
After that, when i scroll totally to the bottom, the last item (the 9) rest
almost totally invisable. This problem disappears, when i open (and close)
one of the nodes. (The sample code uses subnodes only to demonstrate this.
The main problem is the same without the subnodes.)

Does anyone know, why this happens? Is there a solution/workaround to this
problem?

Here the sample code:

using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;
namespace TrewViewTest
{
public partial class Form1 : Form
{
private System.Windows. Forms.TreeView treeView1;
public Form1()
{
InitializeCompo nent();
}
protected override void OnLoad(EventArg s e)
{
base.OnLoad(e);
for (int i = 0; i < 10; i++)
{
treeView1.Nodes .Add(i.ToString ()).Nodes.Add(i .ToString());
}
}
[STAThread]
static void Main()
{
Application.Ena bleVisualStyles ();
Application.Set CompatibleTextR enderingDefault (false);
Application.Run (new Form1());
}
private void InitializeCompo nent()
{
this.treeView1 = new System.Windows. Forms.TreeView( );
this.SuspendLay out();
//
// treeView1
//
this.treeView1. Anchor =
((System.Window s.Forms.AnchorS tyles)((((Syste m.Windows.Forms .AnchorStyles.T op
| System.Windows. Forms.AnchorSty les.Bottom)
| System.Windows. Forms.AnchorSty les.Left)
| System.Windows. Forms.AnchorSty les.Right)));
this.treeView1. Location = new System.Drawing. Point(13, 13);
this.treeView1. Name = "treeView1" ;
this.treeView1. Size = new System.Drawing. Size(267, 120);
this.treeView1. TabIndex = 0;
//
// Form1
//
this.AutoScaleD imensions = new System.Drawing. SizeF(6F, 13F);
this.AutoScaleM ode = System.Windows. Forms.AutoScale Mode.Font;
this.ClientSize = new System.Drawing. Size(292, 266);
this.Controls.A dd(this.treeVie w1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayo ut(false);
}
}
}
Oct 12 '06 #1
6 3234
"Christof Nordiek" wrote:
>when i scroll totally to the bottom, the last item (the 9) rest
almost totally invisable.
What do u mean? You code works fine without hiding anything.

--
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche

Oct 12 '06 #2
"Michael Nemtsev" <ne*****@msn.co mschrieb im Newsbeitrag
news:FC******** *************** ***********@mic rosoft.com...
>"Christof Nordiek" wrote:
>>when i scroll totally to the bottom, the last item (the 9) rest
almost totally invisable.

What do u mean? You code works fine without hiding anything.

--
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do
not
cease to be insipid." (c) Friedrich Nietzsche
Hi Micheal,

on futher investigation i found out, this depends on the visual styles. It
doesn't happen with Windows classic style but f.e. with Windows XP style it
does. Do be exact, it depends on the style, when the form opend resp. was
filled.

Also i should have mentioned, that i used VS 2005. Though i suppose you also
used since the code doesn't compile with VS 2003.

Below i repost the code that is compilable with both. On VS2003 it works
fine on VS2005 it shows the mentioned phenomenon (dependung on Visual
Styles).

using System;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;
namespace TrewViewTest
{
public class Form1 : Form
{
private System.Windows. Forms.TreeView treeView1;
public Form1()
{
InitializeCompo nent();
}
protected override void OnLoad(EventArg s e)
{
base.OnLoad(e);
for (int i = 0; i < 10; i++)
{
treeView1.Nodes .Add(i.ToString ()).Nodes.Add(i .ToString());
}
}
[STAThread]
static void Main()
{
Application.Ena bleVisualStyles ();
Application.Run (new Form1());
}
private void InitializeCompo nent()
{
this.treeView1 = new System.Windows. Forms.TreeView( );
this.SuspendLay out();
//
// treeView1
//
this.treeView1. Anchor =
((System.Window s.Forms.AnchorS tyles)((((Syste m.Windows.Forms .AnchorStyles.T op
| System.Windows. Forms.AnchorSty les.Bottom)
| System.Windows. Forms.AnchorSty les.Left)
| System.Windows. Forms.AnchorSty les.Right)));
this.treeView1. Location = new System.Drawing. Point(13, 13);
this.treeView1. Name = "treeView1" ;
this.treeView1. Size = new System.Drawing. Size(267, 120);
this.treeView1. TabIndex = 0;
//
// Form1
//
this.ClientSize = new System.Drawing. Size(292, 266);
this.Controls.A dd(this.treeVie w1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayo ut(false);
}
}
}


Oct 12 '06 #3
for (int i = 0; i < 10; i++)

If you mean last one is not 10 it is exactly correct because 10 cannot be
lesser than 10. If you want to should 10 using <= 10

chanmm

"Christof Nordiek" <cn@nospam.dewr ote in message
news:e%******** ********@TK2MSF TNGP05.phx.gbl. ..
Hi all,

in my WinForm-Application i have a strange problem with the TreeView
Control.
As you can see in the samplecode below, i fill the TreeView by adding some
nodes with sub nodes. (The subnodes don't matter in the first place.)
After that, when i scroll totally to the bottom, the last item (the 9)
rest almost totally invisable. This problem disappears, when i open (and
close) one of the nodes. (The sample code uses subnodes only to
demonstrate this. The main problem is the same without the subnodes.)

Does anyone know, why this happens? Is there a solution/workaround to this
problem?

Here the sample code:

using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;
namespace TrewViewTest
{
public partial class Form1 : Form
{
private System.Windows. Forms.TreeView treeView1;
public Form1()
{
InitializeCompo nent();
}
protected override void OnLoad(EventArg s e)
{
base.OnLoad(e);
for (int i = 0; i < 10; i++)
{
treeView1.Nodes .Add(i.ToString ()).Nodes.Add(i .ToString());
}
}
[STAThread]
static void Main()
{
Application.Ena bleVisualStyles ();
Application.Set CompatibleTextR enderingDefault (false);
Application.Run (new Form1());
}
private void InitializeCompo nent()
{
this.treeView1 = new System.Windows. Forms.TreeView( );
this.SuspendLay out();
//
// treeView1
//
this.treeView1. Anchor =
((System.Window s.Forms.AnchorS tyles)((((Syste m.Windows.Forms .AnchorStyles.T op
| System.Windows. Forms.AnchorSty les.Bottom)
| System.Windows. Forms.AnchorSty les.Left)
| System.Windows. Forms.AnchorSty les.Right)));
this.treeView1. Location = new System.Drawing. Point(13, 13);
this.treeView1. Name = "treeView1" ;
this.treeView1. Size = new System.Drawing. Size(267, 120);
this.treeView1. TabIndex = 0;
//
// Form1
//
this.AutoScaleD imensions = new System.Drawing. SizeF(6F, 13F);
this.AutoScaleM ode = System.Windows. Forms.AutoScale Mode.Font;
this.ClientSize = new System.Drawing. Size(292, 266);
this.Controls.A dd(this.treeVie w1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayo ut(false);
}
}
}


Oct 12 '06 #4
No i'm not speaking about the 10.
If you read my post well you will see that i'm talking about the 9.
The phenomenon prescribed is dependent an from the visual styles (look in my
response to Michael Nemtsev)
"chanmm" <ch*****@hotmai l.comschrieb im Newsbeitrag
news:OX******** ******@TK2MSFTN GP02.phx.gbl...
for (int i = 0; i < 10; i++)

If you mean last one is not 10 it is exactly correct because 10 cannot be
lesser than 10. If you want to should 10 using <= 10

chanmm

"Christof Nordiek" <cn@nospam.dewr ote in message
news:e%******** ********@TK2MSF TNGP05.phx.gbl. ..
>Hi all,

in my WinForm-Application i have a strange problem with the TreeView
Control.
As you can see in the samplecode below, i fill the TreeView by adding
some nodes with sub nodes. (The subnodes don't matter in the first
place.)
After that, when i scroll totally to the bottom, the last item (the 9)
rest almost totally invisable. This problem disappears, when i open (and
close) one of the nodes. (The sample code uses subnodes only to
demonstrate this. The main problem is the same without the subnodes.)

Does anyone know, why this happens? Is there a solution/workaround to
this problem?

Here the sample code:

using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;
namespace TrewViewTest
{
public partial class Form1 : Form
{
private System.Windows. Forms.TreeView treeView1;
public Form1()
{
InitializeComp onent();
}
protected override void OnLoad(EventArg s e)
{
base.OnLoad(e) ;
for (int i = 0; i < 10; i++)
{
treeView1.Node s.Add(i.ToStrin g()).Nodes.Add( i.ToString());
}
}
[STAThread]
static void Main()
{
Application.En ableVisualStyle s();
Application.Se tCompatibleText RenderingDefaul t(false);
Application.Ru n(new Form1());
}
private void InitializeCompo nent()
{
this.treeVie w1 = new System.Windows. Forms.TreeView( );
this.SuspendLa yout();
//
// treeView1
//
this.treeView1 .Anchor =
((System.Windo ws.Forms.Anchor Styles)((((Syst em.Windows.Form s.AnchorStyles. Top
| System.Windows. Forms.AnchorSty les.Bottom)
| System.Windows. Forms.AnchorSty les.Left)
| System.Windows. Forms.AnchorSty les.Right)));
this.treeView1 .Location = new System.Drawing. Point(13, 13);
this.treeView1 .Name = "treeView1" ;
this.treeView1 .Size = new System.Drawing. Size(267, 120);
this.treeView1 .TabIndex = 0;
//
// Form1
//
this.AutoScale Dimensions = new System.Drawing. SizeF(6F, 13F);
this.AutoScale Mode = System.Windows. Forms.AutoScale Mode.Font;
this.ClientSiz e = new System.Drawing. Size(292, 266);
this.Controls. Add(this.treeVi ew1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLay out(false);
}
}
}



Oct 12 '06 #5
I've solved this putting BeginUpdate & EndUpdate around the population
code:

treeView1.Begin Update();
for (int i = 0; i < 10; i++)
{
treeView1.Nodes .Add(i.ToString ()).Nodes.Add(i .ToString());
}
treeView1.EndUp date();

Got the idea from here:
http://forums.microsoft.com/MSDN/Sho...48930&SiteID=1

Russ

Christof Nordiek wrote:
Hi all,

in my WinForm-Application i have a strange problem with the TreeView
Control.
As you can see in the samplecode below, i fill the TreeView by adding some
nodes with sub nodes. (The subnodes don't matter in the first place.)
After that, when i scroll totally to the bottom, the last item (the 9) rest
almost totally invisable. This problem disappears, when i open (and close)
one of the nodes. (The sample code uses subnodes only to demonstrate this.
The main problem is the same without the subnodes.)

Does anyone know, why this happens? Is there a solution/workaround to this
problem?

Here the sample code:

using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;
namespace TrewViewTest
{
public partial class Form1 : Form
{
private System.Windows. Forms.TreeView treeView1;
public Form1()
{
InitializeCompo nent();
}
protected override void OnLoad(EventArg s e)
{
base.OnLoad(e);
for (int i = 0; i < 10; i++)
{
treeView1.Nodes .Add(i.ToString ()).Nodes.Add(i .ToString());
}
}
[STAThread]
static void Main()
{
Application.Ena bleVisualStyles ();
Application.Set CompatibleTextR enderingDefault (false);
Application.Run (new Form1());
}
private void InitializeCompo nent()
{
this.treeView1 = new System.Windows. Forms.TreeView( );
this.SuspendLay out();
//
// treeView1
//
this.treeView1. Anchor =
((System.Window s.Forms.AnchorS tyles)((((Syste m.Windows.Forms .AnchorStyles.T op
| System.Windows. Forms.AnchorSty les.Bottom)
| System.Windows. Forms.AnchorSty les.Left)
| System.Windows. Forms.AnchorSty les.Right)));
this.treeView1. Location = new System.Drawing. Point(13, 13);
this.treeView1. Name = "treeView1" ;
this.treeView1. Size = new System.Drawing. Size(267, 120);
this.treeView1. TabIndex = 0;
//
// Form1
//
this.AutoScaleD imensions = new System.Drawing. SizeF(6F, 13F);
this.AutoScaleM ode = System.Windows. Forms.AutoScale Mode.Font;
this.ClientSize = new System.Drawing. Size(292, 266);
this.Controls.A dd(this.treeVie w1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayo ut(false);
}
}
}
Oct 13 '06 #6
Hi russ,

thanks, that works!!
I suppose, they should be could anyway (though only for performance
reasens).

"russ" <ru************ *****@gmail.com schrieb im Newsbeitrag
news:11******** **************@ f16g2000cwb.goo glegroups.com.. .
I've solved this putting BeginUpdate & EndUpdate around the population
code:

treeView1.Begin Update();
for (int i = 0; i < 10; i++)
{
treeView1.Nodes .Add(i.ToString ()).Nodes.Add(i .ToString());
}
treeView1.EndUp date();

Got the idea from here:
http://forums.microsoft.com/MSDN/Sho...48930&SiteID=1

Russ

Christof Nordiek wrote:
>Hi all,

in my WinForm-Application i have a strange problem with the TreeView
Control.
As you can see in the samplecode below, i fill the TreeView by adding
some
nodes with sub nodes. (The subnodes don't matter in the first place.)
After that, when i scroll totally to the bottom, the last item (the 9)
rest
almost totally invisable. This problem disappears, when i open (and
close)
one of the nodes. (The sample code uses subnodes only to demonstrate
this.
The main problem is the same without the subnodes.)

Does anyone know, why this happens? Is there a solution/workaround to
this
problem?

Here the sample code:

using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;
namespace TrewViewTest
{
public partial class Form1 : Form
{
private System.Windows. Forms.TreeView treeView1;
public Form1()
{
InitializeComp onent();
}
protected override void OnLoad(EventArg s e)
{
base.OnLoad(e) ;
for (int i = 0; i < 10; i++)
{
treeView1.Node s.Add(i.ToStrin g()).Nodes.Add( i.ToString());
}
}
[STAThread]
static void Main()
{
Application.En ableVisualStyle s();
Application.Se tCompatibleText RenderingDefaul t(false);
Application.Ru n(new Form1());
}
private void InitializeCompo nent()
{
this.treeVie w1 = new System.Windows. Forms.TreeView( );
this.SuspendLa yout();
//
// treeView1
//
this.treeView1 .Anchor =
((System.Windo ws.Forms.Anchor Styles)((((Syst em.Windows.Form s.AnchorStyles. Top
| System.Windows. Forms.AnchorSty les.Bottom)
| System.Windows. Forms.AnchorSty les.Left)
| System.Windows. Forms.AnchorSty les.Right)));
this.treeView1 .Location = new System.Drawing. Point(13, 13);
this.treeView1 .Name = "treeView1" ;
this.treeView1 .Size = new System.Drawing. Size(267, 120);
this.treeView1 .TabIndex = 0;
//
// Form1
//
this.AutoScale Dimensions = new System.Drawing. SizeF(6F, 13F);
this.AutoScale Mode = System.Windows. Forms.AutoScale Mode.Font;
this.ClientSiz e = new System.Drawing. Size(292, 266);
this.Controls. Add(this.treeVi ew1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLay out(false);
}
}
}

Oct 13 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1518
by: Jan Krouwer | last post by:
I have a treeview which is populated from a relational database. In order to copy part of the tree, I need to add to the database the relationship of the part of the tree to be copied but with new ids. I have built a collection of the right number of ids. I am using the following code to recursively go through the tree (some code left out). Pos is the position in the collection of ids - I need to select the correct ids (need to use previous...
2
7084
by: tmaster | last post by:
I can detect a right click on my treeview, but SelectedNode.Index points to the last node that was left-clicked. Is there a way for a right-click event of a treeview to update the SelectedNode.Index? Private Sub tvwTopics_Mouseup(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles tvwTopics.MouseUp If e.Button = MouseButtons.Right Then MsgBox("Right click " &...
6
4922
by: L.M | last post by:
Hello, I knew how to use the treeview under VB6. After migrating to .NET, well, I'm lost. I try to add a new node, either to the same level or as a child to a selected node in the treeview. However, either it only add it to the root level or it only add it on level below, doesn't matter what I select. And in some case, I just get an exception.
12
587
by: Bob Hollness | last post by:
Hi. I have a text file containing a list of files and their path. I.e. c:\MyDocs\File1.txt c:\MyDocs\File2.txt c:\MyDocs\File3.txt c:\MyDocs\File4.txt C:\MyDocs\Folder\File1.txt
7
3762
by: amruta | last post by:
the code below dows not let me get the parent child view... all the nodes are show in one line only... also i need them to be collasped ... Thanks ..
5
5807
by: Paul | last post by:
Hi, I am a self taught VBA programmer, and I'm trying to learn VB2005 Express (The price was right). I like the look of the treeview control, and I'd like to use it as a menu system for my users, the options they are allowed to see are all different and specified in a MSACCESS table. Can I populate a Treeview directly from my MSAccess table ? I can then of course filter the table to only show that users options.
1
2170
by: Christof Nordiek | last post by:
Hi, in my app i use a treeview. If the treeview isn't large enough to show all items it automoatically gets a vertical scrollbar. But i can't always scroll to the last item. Sometimes the last item remains (partially) hidden if i track the scrollbar to the bottom. Even when i navigating with the arrow-keys to the last item it remains invisable. Does someone know a workaround for this issue?
0
3298
by: divya1949 | last post by:
Create a windows c# application which will Read a xml file and populate nodes in the treeview. 1 On selection of treenode display the child nodes of that node in listview control 2. Provide following view properties to listview, through View menu a. Tile b. Icon
4
3580
by: jmDesktop | last post by:
I have searched everywhere and tried several things. I have a treeview with and want to be able to only select a parent node. For example: root //don't want to drag this -parent1 //yes, drag this an only this because it is a parent --childOfParent1 //cannot drag this, only the parent --childOfParent1 //can only drag parent -parent2 //yes, parent, can select and drag --childOfParent2 //no, cannot drag
0
8448
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8783
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7387
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2773
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1776
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.