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);
}
}
}