hi Jeffrey,
thanks for the reply. it seems to be to do with the way i build my
treenodes. i start with a root node, and add all the children to that. it
seems that unless the child nodes are added directly to the tree, they do
not get any bounds.
you can reproduce this with the following code:
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Web;
namespace Test
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TreeView treeView1;
private System.Windows.Forms.TextBox textBox1;
private System.ComponentModel.IContainer components = null;
public Form1()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.treeView1 = new System.Windows.Forms.TreeView();
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// treeView1
//
this.treeView1.Dock = System.Windows.Forms.DockStyle.Left;
this.treeView1.ImageIndex = -1;
this.treeView1.Location = new System.Drawing.Point(0, 0);
this.treeView1.Name = "treeView1";
this.treeView1.SelectedImageIndex = -1;
this.treeView1.Size = new System.Drawing.Size(232, 396);
this.treeView1.TabIndex = 0;
//
// textBox1
//
this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.textBox1.Location = new System.Drawing.Point(232, 0);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(304, 396);
this.textBox1.TabIndex = 1;
this.textBox1.Text = "";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(536, 396);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.treeView1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
TreeNode root = new TreeNode("Node1");
root.Nodes.Add(new TreeNode("Node2"));
root.Nodes.Add(new TreeNode("Node3"));
root.Nodes.Add(new TreeNode("Node4"));
this.treeView1.Nodes.Add(root);
foreach(TreeNode node in root.Nodes)
this.textBox1.Text += node.Bounds.ToString() + "\r\n";
}
}
}
i wouldn't have thought there was anything weird about my approach above
(which is simplified). recursion is used a lot with treeviews.
do i get a prize for finding a bug in the treeview?
tim
--------------------------
blog:
http://tim.mackey.ie
"Jeffrey Tan[MSFT]" said:
Hi Tim,
Thanks for your post.
I am not sure where does this code snippet executed. I have tried it in
TreeView.BeforeSelect and other methods, TreeView.Bounds will return the
correct values.
Can you provide a little sample project for us to reproduce your problem?
Thanks
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.