{"id":293,"date":"2013-10-16T14:31:12","date_gmt":"2013-10-16T12:31:12","guid":{"rendered":"http:\/\/gator4228.temp.domains\/~vasiljevski\/blog\/?p=293"},"modified":"2018-05-16T03:48:41","modified_gmt":"2018-05-16T01:48:41","slug":"how-to-fix-last-item-not-visible-in-treeview","status":"publish","type":"post","link":"https:\/\/www.vasiljevski.com\/blog\/net-framework\/how-to-fix-last-item-not-visible-in-treeview\/","title":{"rendered":"How to fix: &#8220;last item not visible in TreeView&#8221;"},"content":{"rendered":"<p>As reported this problem is somehow related to Visual Styles usage in .Net. This is known issue and is recognized by Microsoft. There are a few ways to fix this problem. Let&#8217;s start with the easiest one. Note that this problem occurs in cases when treeView is dynamically populated.<br \/>\n<!--more--><br \/>\nDisabling visual styles is the easy solution, but not suitable in case you need visual styles to be enabled.<\/p>\n<p>Another solution is to always use treeView.BeginUpdate() (before) and treeView.EndUpdate()\u00a0 (after) you populate your treeView. This not only that solves the problem with the missing last item it also improves performance. But it should be used carefully and watch out not to overuse it . Here is a bad example:<\/p>\n<pre lang=\"csharp\">foreach (TreeNode node in treeView.Nodes)\r\n{\r\n    treeView.BeginUpdate();\r\n    node.Text += node.Text + (\" (Selected) \");\r\n    treeView.EndUpdate();\r\n}<\/pre>\n<p>Calling treeView.EndUpdate() causes the treeView to be redrawn but if we call it to often we end up with the same issue we had in the first place, performance.<br \/>\nCorrect example would be:<\/p>\n<pre lang=\"csharp\">\r\ntreeView.BeginUpdate();\r\nforeach (TreeNode node in treeView.Nodes)\r\n{\r\n    node.Text += node.Text + (\" (Selected) \");\r\n}\r\ntreeView.EndUpdate();<\/pre>\n<p>Hope this helps someone struggling with the similar issue.<br \/>\nIf anyone has something to add or improve post a comment.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As reported this problem is somehow related to Visual Styles usage in .Net. This is known issue and is recognized by Microsoft. There are a few ways to fix this problem. Let&#8217;s start with the easiest one. Note that this problem occurs in cases when treeView is dynamically populated.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35],"tags":[],"class_list":["post-293","post","type-post","status-publish","format-standard","hentry","category-net-framework","content","has-not-featured-image"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to fix: &quot;last item not visible in TreeView&quot; - Vasiljevski Nikola<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vasiljevski.com\/blog\/net-framework\/how-to-fix-last-item-not-visible-in-treeview\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to fix: &quot;last item not visible in TreeView&quot; - Vasiljevski Nikola\" \/>\n<meta property=\"og:description\" content=\"As reported this problem is somehow related to Visual Styles usage in .Net. This is known issue and is recognized by Microsoft. There are a few ways to fix this problem. Let&#8217;s start with the easiest one. Note that this problem occurs in cases when treeView is dynamically populated.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vasiljevski.com\/blog\/net-framework\/how-to-fix-last-item-not-visible-in-treeview\/\" \/>\n<meta property=\"og:site_name\" content=\"Vasiljevski Nikola\" \/>\n<meta property=\"article:publisher\" content=\"vasiljevski\/\" \/>\n<meta property=\"article:author\" content=\"vasiljevski\/\" \/>\n<meta property=\"article:published_time\" content=\"2013-10-16T12:31:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-05-16T01:48:41+00:00\" \/>\n<meta name=\"author\" content=\"Nikola Vasiljevski\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vasiljevski\" \/>\n<meta name=\"twitter:site\" content=\"@vasiljevski\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nikola Vasiljevski\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.vasiljevski.com\\\/blog\\\/net-framework\\\/how-to-fix-last-item-not-visible-in-treeview\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.vasiljevski.com\\\/blog\\\/net-framework\\\/how-to-fix-last-item-not-visible-in-treeview\\\/\"},\"author\":{\"name\":\"Nikola Vasiljevski\",\"@id\":\"https:\\\/\\\/www.vasiljevski.com\\\/blog\\\/#\\\/schema\\\/person\\\/509c89ff2a8cf276387db60304561957\"},\"headline\":\"How to fix: &#8220;last item not visible in TreeView&#8221;\",\"datePublished\":\"2013-10-16T12:31:12+00:00\",\"dateModified\":\"2018-05-16T01:48:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.vasiljevski.com\\\/blog\\\/net-framework\\\/how-to-fix-last-item-not-visible-in-treeview\\\/\"},\"wordCount\":183,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.vasiljevski.com\\\/blog\\\/#\\\/schema\\\/person\\\/509c89ff2a8cf276387db60304561957\"},\"articleSection\":[\".NET\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.vasiljevski.com\\\/blog\\\/net-framework\\\/how-to-fix-last-item-not-visible-in-treeview\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.vasiljevski.com\\\/blog\\\/net-framework\\\/how-to-fix-last-item-not-visible-in-treeview\\\/\",\"url\":\"https:\\\/\\\/www.vasiljevski.com\\\/blog\\\/net-framework\\\/how-to-fix-last-item-not-visible-in-treeview\\\/\",\"name\":\"How to fix: \\\"last item not visible in TreeView\\\" - Vasiljevski Nikola\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.vasiljevski.com\\\/blog\\\/#website\"},\"datePublished\":\"2013-10-16T12:31:12+00:00\",\"dateModified\":\"2018-05-16T01:48:41+00:00\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.vasiljevski.com\\\/blog\\\/net-framework\\\/how-to-fix-last-item-not-visible-in-treeview\\\/\"]}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.vasiljevski.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.vasiljevski.com\\\/blog\\\/\",\"name\":\"Vasiljevski Nikola\",\"description\":\"Art is never finished, only abandoned\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.vasiljevski.com\\\/blog\\\/#\\\/schema\\\/person\\\/509c89ff2a8cf276387db60304561957\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.vasiljevski.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.vasiljevski.com\\\/blog\\\/#\\\/schema\\\/person\\\/509c89ff2a8cf276387db60304561957\",\"name\":\"Nikola Vasiljevski\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ec57b2f6f160422547bf7c9839dcdea6dec9a50dddffae650a5a393fea6953ec?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ec57b2f6f160422547bf7c9839dcdea6dec9a50dddffae650a5a393fea6953ec?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ec57b2f6f160422547bf7c9839dcdea6dec9a50dddffae650a5a393fea6953ec?s=96&r=g\",\"caption\":\"Nikola Vasiljevski\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ec57b2f6f160422547bf7c9839dcdea6dec9a50dddffae650a5a393fea6953ec?s=96&r=g\"},\"sameAs\":[\"https:\\\/\\\/www.vasiljevski.com\",\"vasiljevski\\\/\",\"https:\\\/\\\/x.com\\\/vasiljevski\",\"nikola83\"],\"url\":\"https:\\\/\\\/www.vasiljevski.com\\\/blog\\\/author\\\/nikola\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to fix: \"last item not visible in TreeView\" - Vasiljevski Nikola","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.vasiljevski.com\/blog\/net-framework\/how-to-fix-last-item-not-visible-in-treeview\/","og_locale":"en_US","og_type":"article","og_title":"How to fix: \"last item not visible in TreeView\" - Vasiljevski Nikola","og_description":"As reported this problem is somehow related to Visual Styles usage in .Net. This is known issue and is recognized by Microsoft. There are a few ways to fix this problem. Let&#8217;s start with the easiest one. Note that this problem occurs in cases when treeView is dynamically populated.","og_url":"https:\/\/www.vasiljevski.com\/blog\/net-framework\/how-to-fix-last-item-not-visible-in-treeview\/","og_site_name":"Vasiljevski Nikola","article_publisher":"vasiljevski\/","article_author":"vasiljevski\/","article_published_time":"2013-10-16T12:31:12+00:00","article_modified_time":"2018-05-16T01:48:41+00:00","author":"Nikola Vasiljevski","twitter_card":"summary_large_image","twitter_creator":"@vasiljevski","twitter_site":"@vasiljevski","twitter_misc":{"Written by":"Nikola Vasiljevski","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.vasiljevski.com\/blog\/net-framework\/how-to-fix-last-item-not-visible-in-treeview\/#article","isPartOf":{"@id":"https:\/\/www.vasiljevski.com\/blog\/net-framework\/how-to-fix-last-item-not-visible-in-treeview\/"},"author":{"name":"Nikola Vasiljevski","@id":"https:\/\/www.vasiljevski.com\/blog\/#\/schema\/person\/509c89ff2a8cf276387db60304561957"},"headline":"How to fix: &#8220;last item not visible in TreeView&#8221;","datePublished":"2013-10-16T12:31:12+00:00","dateModified":"2018-05-16T01:48:41+00:00","mainEntityOfPage":{"@id":"https:\/\/www.vasiljevski.com\/blog\/net-framework\/how-to-fix-last-item-not-visible-in-treeview\/"},"wordCount":183,"commentCount":0,"publisher":{"@id":"https:\/\/www.vasiljevski.com\/blog\/#\/schema\/person\/509c89ff2a8cf276387db60304561957"},"articleSection":[".NET"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.vasiljevski.com\/blog\/net-framework\/how-to-fix-last-item-not-visible-in-treeview\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.vasiljevski.com\/blog\/net-framework\/how-to-fix-last-item-not-visible-in-treeview\/","url":"https:\/\/www.vasiljevski.com\/blog\/net-framework\/how-to-fix-last-item-not-visible-in-treeview\/","name":"How to fix: \"last item not visible in TreeView\" - Vasiljevski Nikola","isPartOf":{"@id":"https:\/\/www.vasiljevski.com\/blog\/#website"},"datePublished":"2013-10-16T12:31:12+00:00","dateModified":"2018-05-16T01:48:41+00:00","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vasiljevski.com\/blog\/net-framework\/how-to-fix-last-item-not-visible-in-treeview\/"]}]},{"@type":"WebSite","@id":"https:\/\/www.vasiljevski.com\/blog\/#website","url":"https:\/\/www.vasiljevski.com\/blog\/","name":"Vasiljevski Nikola","description":"Art is never finished, only abandoned","publisher":{"@id":"https:\/\/www.vasiljevski.com\/blog\/#\/schema\/person\/509c89ff2a8cf276387db60304561957"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vasiljevski.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.vasiljevski.com\/blog\/#\/schema\/person\/509c89ff2a8cf276387db60304561957","name":"Nikola Vasiljevski","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/ec57b2f6f160422547bf7c9839dcdea6dec9a50dddffae650a5a393fea6953ec?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/ec57b2f6f160422547bf7c9839dcdea6dec9a50dddffae650a5a393fea6953ec?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ec57b2f6f160422547bf7c9839dcdea6dec9a50dddffae650a5a393fea6953ec?s=96&r=g","caption":"Nikola Vasiljevski"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/ec57b2f6f160422547bf7c9839dcdea6dec9a50dddffae650a5a393fea6953ec?s=96&r=g"},"sameAs":["https:\/\/www.vasiljevski.com","vasiljevski\/","https:\/\/x.com\/vasiljevski","nikola83"],"url":"https:\/\/www.vasiljevski.com\/blog\/author\/nikola\/"}]}},"_links":{"self":[{"href":"https:\/\/www.vasiljevski.com\/blog\/wp-json\/wp\/v2\/posts\/293","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vasiljevski.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.vasiljevski.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.vasiljevski.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vasiljevski.com\/blog\/wp-json\/wp\/v2\/comments?post=293"}],"version-history":[{"count":18,"href":"https:\/\/www.vasiljevski.com\/blog\/wp-json\/wp\/v2\/posts\/293\/revisions"}],"predecessor-version":[{"id":310,"href":"https:\/\/www.vasiljevski.com\/blog\/wp-json\/wp\/v2\/posts\/293\/revisions\/310"}],"wp:attachment":[{"href":"https:\/\/www.vasiljevski.com\/blog\/wp-json\/wp\/v2\/media?parent=293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vasiljevski.com\/blog\/wp-json\/wp\/v2\/categories?post=293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vasiljevski.com\/blog\/wp-json\/wp\/v2\/tags?post=293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}