TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Dong Lam Trien
827
986
147.1k
How to set icons for the windows forms treeview control ?
Mar 26 2020 11:42 PM
I use imageList to store icons and I assign imageList to treeView, I use treeView1_DrawNode to change icon for treeView but this function does not run. See my photo and code below.
namespace
TreeView
{
public
partial
class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
treeView1.ImageList = imageList1;
this
.treeView1.DrawNode +=
new
System.Windows.Forms.DrawTreeNodeEventHandler(
this
.treeView1_DrawNode);
dt = CreateTable(10);
CreateTreeView(dt, treeView1,
true
);
}
DataTable dt =
new
DataTable();
...
//My code
private
void
treeView1_DrawNode(
object
sender, DrawTreeNodeEventArgs e)
{
if
(e.Node.IsExpanded || e.Node.Nodes.Count < 1)
treeView1.ImageIndex = 0;
else
treeView1.ImageIndex = 1;
}
}
http://www.mediafire.com/file/iz4mvxfu9o0h863/treeView01.jpg
Why is the treeView1_DrawNode(...) function not running? How to change my treeView icons instead of +,- like a windows explorer treeview in win forms?
Reply
Answers (
4
)
Deny paste link in browser csharp
How to Publish C# App along with remotely central database?