{"id":158,"date":"2009-11-23T13:09:01","date_gmt":"2009-11-23T13:09:01","guid":{"rendered":""},"modified":"2009-11-23T13:09:01","modified_gmt":"2009-11-23T13:09:01","slug":"powertoolbar-managing-dropcombo-control","status":"publish","type":"post","link":"http:\/\/www.icetips.com\/blog_wp\/2009\/11\/23\/powertoolbar-managing-dropcombo-control\/","title":{"rendered":"PowerToolbar:  Managing DropCombo control items"},"content":{"rendered":"<p>I got an email this morning from a customer who was trying, without any success, to change the text of items in a Drop Combo control in PowerToolbar at runtime.  The simplest way would be to simply use:<\/p>\n<div style=\"border: 1px solid gray;padding: 2px;background:#FBFFE8;margin-bottom:10px\">\n<pre>\r\nToolbar1.SetItemText(MyItem,'My Text')\r\n<\/pre>\n<\/div>\n<p>Unfortunately that only works for drop buttons, not Drop Combos.  I figured it would be a simple task to add a method to do this but ran into a brick wall.  The brick wall was the APIs used to construct Drop down Combo controls do not have any messages or methods to change the text for a given item!  It seems to be set in stone once the item is created.  So what can you do?  The simple answer is to recreate the Drop Combo items!  It is very fast and as far as I can tell it does not cause any flicker.  <\/p>\n<p>If you want to restore the text in the entry field, you need a single CSTRING variable to contain the text.  Below is the code needed to reset the items in the Drop Combo:<\/p>\n<div style=\"border: 1px solid gray;padding: 2px;background:#FBFFE8;margin-bottom:10px\">\n<pre>\r\nLoc:Str = Toolbar1.GetText(ID1_DropCombo)\r\nToolbar1.DeleteItems(ID1_DropCombo)\r\nToolbar1.AddComboItem(ID1_DropCombo, 'NEW Drop combo item 1', )\r\nToolbar1.AddComboItem(ID1_DropCombo, 'NEW Drop combo item 2', )\r\nToolbar1.SetText(ID1_DropCombo,Loc:Str)\r\n<\/pre>\n<\/div>\n<p>In this case <b>Loc:Str <\/b>is a CSTRING(100) variable that is a temporary buffer for the contents of the Drop Combo edit control.  The <b>Toolbar1.DeleteItems<\/b> deletes ALL the items from the list and the next two <b>Toolbar1.AddComboItem<\/b> lines add two new items to the list.  The <b>Toolbar1.SetText<\/b> resets the text in the edit control and you are back where you started except you now have updated items in your list.<\/p>\n<p>Arnor Baldvinsson<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_158\" class=\"pvc_stats all  \" data-element-id=\"158\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"http:\/\/www.icetips.com\/blog_wp\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>I got an email this morning from a customer who was trying, without any success, to change the text of items in a Drop Combo control in PowerToolbar at runtime. The simplest way would be to simply use: Toolbar1.SetItemText(MyItem,'My Text') Unfortunately that only works for drop buttons, not Drop Combos. I figured it would be <a href=\"http:\/\/www.icetips.com\/blog_wp\/2009\/11\/23\/powertoolbar-managing-dropcombo-control\/\" class=\"more-link\">...continue reading <span class=\"screen-reader-text\">PowerToolbar:  Managing DropCombo control items<\/span><\/a><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_158\" class=\"pvc_stats all  \" data-element-id=\"158\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"http:\/\/www.icetips.com\/blog_wp\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[8,4,5],"tags":[],"class_list":["post-158","post","type-post","status-publish","format-standard","hentry","category-faq","category-products","category-technical"],"_links":{"self":[{"href":"http:\/\/www.icetips.com\/blog_wp\/wp-json\/wp\/v2\/posts\/158","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.icetips.com\/blog_wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.icetips.com\/blog_wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.icetips.com\/blog_wp\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.icetips.com\/blog_wp\/wp-json\/wp\/v2\/comments?post=158"}],"version-history":[{"count":0,"href":"http:\/\/www.icetips.com\/blog_wp\/wp-json\/wp\/v2\/posts\/158\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.icetips.com\/blog_wp\/wp-json\/wp\/v2\/media?parent=158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.icetips.com\/blog_wp\/wp-json\/wp\/v2\/categories?post=158"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.icetips.com\/blog_wp\/wp-json\/wp\/v2\/tags?post=158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}