473,386 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

TreeView selectednode ghosting problem

Hello,
I have an app that has a custom treeview which inherits the base
treeview class and I am having a problem with the way the treeview is
being redrawn. Each node in the treeview represents a folder, and
this problem began when I added the functionality to have a ghost
image of the folder when it is dragged and dropped to another location
in the treeview. My code to create the ghost image is as follows:

this.NodeToBeDeleted = (FolderNode)e.Item;
this.folderTreeView.NodeToBeDeleted = (FolderNode)e.Item;
string strItem = e.Item.ToString();
//this.folderTreeView.SelectedNode = this.NodeToBeDeleted;

// Reset image list used for drag image
this.imageListDrag.Images.Clear();
this.imageListDrag.ImageSize =
new Size(this.NodeToBeDeleted.Bounds.Size.Width
+ this.folderTreeView.Indent,
this.NodeToBeDeleted.Bounds.Height);

// Create new bitmap
// This bitmap will contain the tree node image to be dragged
Bitmap bmp = new Bitmap(this.NodeToBeDeleted.Bounds.Width
+ this.folderTreeView.Indent, this.NodeToBeDeleted.Bounds.Height);

// Get graphics from bitmap
Graphics gfx = Graphics.FromImage(bmp);

// Draw node icon into the bitmap

gfx.DrawImage(folderTreeViewImageList.Images[NodeToBeDeleted.ImageIndex],
0, 0);

// Draw node label into bitmap
gfx.DrawString(this.NodeToBeDeleted.Text,
this.folderTreeView.Font,
new SolidBrush(this.folderTreeView.ForeColor),
(float)this.folderTreeView.Indent, 1.0f);

Graphics Viewable = folderTreeView.CreateGraphics();
Viewable.DrawImageUnscaled(bmp, 0, 0);

// Add bitmap to imagelist
this.imageListDrag.Images.Add(bmp);

The FolderNode inherits from TreeNode. The problem is that when I
pick up a folder and move it around to be dropped in between other
folders in the treeview, each time another folder is highlighted as
the selected node under the dragged item, a trail of partially
highlighted folders remains from where I had previously dragged. This
is hard to explain, but it just looks like the highlighting for each
node from when it was the selected node is not completely removed. I
have tried several combinations of solutions for this but to no
avail. I did the following in my constructor:

this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
//this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.UpdateStyles();

but the trail remains. Also, the trail was eliminated when I did
BeginUpdate() and EndUpdate() before highlighting each node under the
dragged item, but then the treeview flickers horribly as the dragged
item is moved around. So if there is some way to totally remove the
flicker the beginUpdate and endUpdate would be the answer. Can anyone
provide any insight into this? Thanks.

Oct 29 '07 #1
0 2154

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

Similar topics

4
by: David Elliott | last post by:
Hi, I have a Windows Explorer-like treeview that displays directories. After a cut/paste operation, I want the treeview to display the folder where the paste happened. But, I'm running into a...
13
by: André Nogueira | last post by:
Hi there. I know you can view a node's fullpath property, but is it posible to select a node using its path? Like, tell the treeview that the node that should be selected is the node with the...
5
by: Juanjo | last post by:
I need to know how to maintain de status (nodes expanded and selected) of a treeview in a master page. I have a master page with a treeview. I have a default page, when the treeview is expanded...
6
by: cyriel1920 | last post by:
Hi, I use the selectednodestyle with a white background so the user can see which item was chosen in the treeview navigation. The nodes have a navigateURL with a target to another frame....
2
by: Claus | last post by:
Hello, I have a long treeview with scrollbars. When I scroll down and press a treeview node, then the Load event fires and navigate in an iframe to another page. The problem is, that afterwards...
1
by: tanya foster | last post by:
Hello, I have populated a treeview in asp.net 2.0 from an xmldocument. The treeview structure in the asp web page looks something like... -orderdata -order -lines -operations -materials...
2
by: rfm | last post by:
I have a TreeView with 1 expanded top node, it has several childnodes (call it row A), which have childs of their own. The top node is selected correctly and all childnodes from the row A nodes...
2
by: bg_ie | last post by:
Hi, I have a treeview where the user selects a node before editing it. The problem is that when the user clicks on the text box to edit the node, the treeview loses its focus and the node is no...
3
by: dutsnekcirf | last post by:
I have a treeview control on a custom task pane in Excel. I've enable the ability to use Drag & Drop (by following this how-to) on the treeview to change the order of the nodes. The problem though...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
0
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...

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.