Day 020 - More controls!

Continuing on with the Controls chapter, which on page 177 discussed list boxes. 

List boxes

List boxes can be populated:

  • from a data file (if the query does not yet exist, you have the option of creating it at the same time as you create the list box)
  • from a variable (e.g. an array)
  • with code (either in embed code or by adding the necessary statements to the control's description)

List boxes can also be single-selection or multi-selection. 

As I think I've mentioned before, you can load all the data from a file into a list box (in-memory approach) or you can use direct access, in which case you're limited to no more than 100,000 records. The tutorial seems to indicate that when you're using direct access every time you select a record that record is retrieved from the database, so jumping around in the list box will result in ongoing database traffic, whereas an in-memory list box is a one-time retrieval (although if for some reason you need access to record data not in the list box, or you want to update the record, I expect you're going to have to make a trip back to the database first. 

There are a number of list box management functions, all of which begin with List:

  • FileToMemoryList
  • ListAdd
  • ListCount
  • ListDelete
  • ListDeleteAll
  • ListDisplay
  • ListInfoXY
  • ListInsert
  • ListModify
  • ListMoveLine
  • ListPosition
  • ListSeek
  • ListSelect
  • ListSelectCount
  • ListSelectMinus
  • ListSelectPlus
  • ListSort

This seems like a useful thing to know:

for a browsing list box, if the retrieved value corresponds to a value of the data file, use the name of the list box to find out the selected value

which I gather means using the .. property syntax. Otherwise the examples shown mainly show how use ListSelect to get the row number.

List views

List views are much like list boxes, but they allow you to display both text and images. You can fill these with the ListAdd function or via a data file or query. With the latter you must specify the caption and the image columns. 

List views can also be single or multi select. 

Combo boxes

Nothing too unusual about the combo boxes. They can be populated like other lists, though of course they are drop lists and also allow for user entry. You can make them editable or not editable, and in the latter they're not combo boxes at all  but just regular drop lists (at least if anyone's asking me). 

Table controls

Although you can display data from a database in the list controls already discussed, they are single column only and they don't give the degree of display flexibility you'll usually want. A table control adds multiple columns with headers. 

Table functions include:

  • BuildBrowsingTable
  • FileToMemoryTable
  • TableAdd
  • TableAddColumn
  • TableAddLine
  • TableAdjust
  • TableBreakSubscript
  • TableCellSelect
  • TableCellSelectOccurrence
  • TableColumnSelect
  • TableColumnSelectOccurrence
  • TableColumnSubscript
  • TableCount
  • TableDelete
  • TableDeleteAll
  • TableDisableFilter
  • TableDisplay
  • TableEnableFilter
  • TableEnd
  • TableEnumColumn
  • TableFixColumn
  • TableInfoXY
  • TableInputInProgress
  • TableInputSearch
  • TableInsert
  • TableInsertColumn
  • TableInsertLine
  • TableMode
  • TableModify
  • TableModifyColumn
  • TableModifyLine
  • TableMoveColumn
  • TableMoveLine
  • TablePosition
  • TablePrint
  • TableRecNum
  • TableRestorePositionAndSelection
  • TableSave
  • TableSavePositionAndSelection
  • TableSeek
  • TableSelect
  • TableSelectCount
  • TableSelectMinus
  • TableSelectPlus
  • TableSelectToFile
  • TableSort
  • TableSortedColumn
  • TableSort_55
  • TableToClipboard
  • TableToExcel
  • TableToText
  • TableToWord
  • TableToXML
  • CurrentSubscript
  • NextSubscript

There are also quite a few constants that affect table behavior; you pass these to various table functions. 

You can have a table control that's linked to a query that takes parameters. In this case the wizard will set up some initialization code to supply parameters to the query. 

Table controls support automatic totaling, single selection, multiple section, and row besides row selection they also support column and cell selection. 

Table controls can display a wide range of widgets, from text to images to containers. Containers?

A container can hold a number of other controls; I haven't tried this yet, but it looks pretty interesting. There's some helpful information here

Table controls can be strictly in-memory also - you use the appropriate Table functions to add data. You can select, modify and delete data under program control, and in-line editing can be defined on a per-column basis. 

The sample app also shows how to create a table with "breaks" or section headers.

Looper controls

Looper controls seem to be the cause of a lot of confusion, at least among beginning WinDev users. 

I'm told they have their origin in web development, where it's common to have repeating sets of controls that aren't easily defined as a list control. So in other words, a looper is simply a way to present a set of one or more controls, one or more times. 

Loopers can operate using data from a variable, from a data source such as a query, or they can be controlled by program code. 

So why use a looper instead of a table control? I suppose you could use it whenever you're having trouble getting a table control to bend to your will. But tables only repeat data on one axis. A looper control can repeat on both X and Y axes, and the number of columns can be set as resizable as can the height and width of the rows. 

The word "looper" sounds to me like a one-dimensional repeat; I think of this as a grid control. 

TreeView

The treeview control is a hybrid of a standard tree view and a table control. You can do standard tree-view displays, or you can get a little fancier by adding columns and custom images, as the example shows:

Progress bars

Progress bars show progress. 'Nuff said.

Charts

The last of the general-purpose controls is the chart control, which can be:

  • 2D
  • 3D
  • pie
  • bar
  • stock
  • line
  • scatter
  • etc.

Here's the example:

And with a couple of quick changes, the same chart as a 3D semicircular (values are randomly generated):

Next week I'll get into the special purpose controls, of which there are many - everything from calendars to XAML.