Separate color for separate row listbox

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Separate color for separate row listbox



      I wanted to implement the design similar to attached image.

      I tried to implement this using listbox widget but I am unable to set separate color for each row similar attached image.

      Could you please let me know that is it possible/alternative way to add separate color for separate row in the list?

      • listbox_color_issue.png

        4.91 kB, 459×174, viewed 11 times
    • New


      you can do that by setting an owner draw function to the widget and doing the drawing yourself. Have a look at this sample.

      Unfortunately, there is no WIDGET_ITEM_DRAW_BACKGROUND command, only a WIDGET_ITEM_DRAW command, which means you have to draw each item completely (background, text, ...).

      When drawing the item in the WIDGET_ITEM_DRAW case, you can set the background color based on the current item index. The current item index is stored in pDrawItemInfo->ItemIndex.

      Best regards,

    • New


      I don't mean that.

      I wanted to say that if i use multiple button widgets one below another and will set different background color one by another as shown in the image.
      (Here I will not use listbox/listview buttons). I think this will not be possible to scroll the normal button, I may need to change the requirement.


      The post was edited 2 times, last by vikramtathe ().

    • New


      I am referring "WIDGET_ListBoxOwnerDraw.c" sample example code.

      As image attached in the first post, I can able to draw alternate colors to rows in the listbox.

      I tried to adjust the row height for the listbox using LISTBOX_SetItemSpacing(hListBox, 31) but I am unable to achieve this.

      Could you please look at the source code and let me know how to adjust the row height?

      About scrolling, consider the scenario that 6 rows are in the list box and I have added 10 itens in the listbox. I have tried the scroll down by calling LISTBOX_IncSel() in the button callback(Not using scrollbar). Here in this case what happen when I click 6 times on button then only I get the scrolling effect. Is it possible to add offset index in the LISTBOX_IncSel() so that I can get scroll effect in one click.

      • Main.txt

        (9.03 kB, downloaded 4 times, last: )