27.1 Overview

Listview class derives from Area class and shows a list container that can be filled with data items. RapaGUI's listview class is very powerful and supports multi-column lists, checkboxes, editable list items, data sorting via custom callbacks, and icons for the individual listview items.

When creating a listview in XML code, you always have to add at least one column to it. This is done by using Listviewcolumn class. Here is an example of a minimal listview declaration with just a single column:

 
<listview>
   <column/>
</listview>

It is also possible to add some entries to the listview right at declaration time. This can be done by using the <item> tag:

 
<listview>
   <column>
      <item>Entry 1</item>
      <item>Entry 2</item>
      <item>Entry 3</item>
   </column>
</listview>

If you want to have a multi-column list, you need to use the <column> tag several times. Here is an example:

 
<listview>
   <column title="Column 1">
      <item>Entry 1</item>
      <item>Entry 2</item>
      <item>Entry 3</item>
   </column>
   <column title="Column 2">
      <item>Entry 1</item>
      <item>Entry 2</item>
      <item>Entry 3</item>
   </column>
   <column title="Column 3">
      <item>Entry 1</item>
      <item>Entry 2</item>
      <item>Entry 3</item>
   </column>
</listview>

In this example we have also made use of the Listviewcolumn.Title attribute to add a title bar to each of our columns. There are some more attributes that you can use to customize the appearance of your columns. For example, you can add checkboxes to your columns and allow the editing of column items. See Listviewcolumn class for details.

Note that RapaGUI might use up to three different kinds of widgets for this class: In case you are creating a listview that doesn't use any advanced functionality (such as multiple columns, icons, sorting) RapaGUI might create a more basic list widget for you because some operating systems offer several kinds of list-based widgets, e.g. on Windows there is a Listbox widget and a Listview widget. RapaGUI will use the Listbox widget in case your listview doesn't use any of the advanced features because listboxes are usually faster than listviews. If you don't want that, you can force RapaGUI to always give you a full-blown listview by setting the Listview.ForceMode attribute to the according tag. See Listview.ForceMode for details.


Show TOC