C
Christof Nordiek
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.Collections.Generic;
using System.ComponentModel;
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()
{
InitializeComponent();
}
protected override void OnLoad(EventArgs 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.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
private void InitializeComponent()
{
this.treeView1 = new System.Windows.Forms.TreeView();
this.SuspendLayout();
//
// treeView1
//
this.treeView1.Anchor =
((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top
| System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.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.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.treeView1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
}
}
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.Collections.Generic;
using System.ComponentModel;
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()
{
InitializeComponent();
}
protected override void OnLoad(EventArgs 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.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
private void InitializeComponent()
{
this.treeView1 = new System.Windows.Forms.TreeView();
this.SuspendLayout();
//
// treeView1
//
this.treeView1.Anchor =
((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top
| System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.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.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.treeView1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
}
}