The class ColumnView in gb.qt4 (→ gb.gui.base) implements a control that displays a TreeView with columns.
The ColumnView class has these properties, among other things:
Property | Data type | Description |
---|---|---|
AutoResize | Boolean | Returns the value or determines whether the width of the last column is automatically adjusted or extended to the content so that the remaining visible area is used. |
Columns | _ColumnView_Columns | Returns a virtual collection of all columns in the column view. |
Count | Integer | Returns the number of all rows. |
Current | _TreeView_Item | Returns the current row - the row that has the focus or is selected/selected in single mode. |
Header | Boolean | Specifies whether a header with the column headings is visible or not. If the boolean value is True, then the first line is interpreted as header and the index for all further lines starts with 1. |
Item | _TreeView_Item | Returns the line to which the internal pointer points. Returns NULL if the internal pointer is not available. |
Key | String | Returns the key of a line. |
Resizable | Boolean | Shows whether or not the columns are resizable with the mouse. |
Sorted | Booelan | Specifies whether the row is sorted or not. |
Table 17.5.0.0.1.1: Selected properties of the ColumnView class
Class _ColumnView_Columns:
The _ColumnView_Columns class has only these four properties:
Ascending As Boolean Specifies whether the sorting is set to ascending or descending. Count As Integer Returns or sets the number of columns. Max As Integer Returns the largest column index. Sort As Integer Returns the column index used to sort the ColumnView row or determines this column using the index. The value -1 indicates that the rows are not sorted.
In the following example, a column is returned - according to its index - whose 4 properties you can then query, for example:
Dim hColumnView As ColumnView Dim hGridViewColumn As _ColumnView_Columns hGridViewColumn = hColumnView.Columns[ Index As Integer ] Print hGridViewColumn.Count ' hColumnView.Columns[Index As Integer].Count Print hGridViewColumn.Max ' hColumnView.Columns[Index As Integer].Max Print hGridViewColumn.Sort ' hColumnView.Columns[Index As Integer].Sort Print hGridViewColumn.Ascending ' hColumnView.Columns[Index As Integer].Ascending
The ColumnView class has these selected methods:
Method | Return type | Description |
---|---|---|
Exist (Key As String) | Boolean | Returns the value True if the line with the specified key exists. |
Clear () | ~ | Deletes all rows. An existing header line remains completely intact! |
MoveBack () | Boolean | If one of the other Move methods returns the value True, you can use this method to move the internal pointer to its original position. True is returned if the internal pointer was not at a valid position. |
MoveBelow () | Boolean | Moves the internal pointer to a line below the current one. True is returned if the move cannot be executed. |
MoveTo ([ Key As String]) | Boolean | Sets the internal pointer to the row with the specified key in a ColumnView. |
MoveBelow () | Boolean | Moves the internal pointer to a line below the current one. True is returned if the move cannot be executed. |
MoveFirst () | Boolean | Sets the internal pointer in the ColumnView to the first line. True is returned if the list is empty. |
MoveLast () | Boolean | Sets the internal pointer in the ColumnView to the last line. True is returned if the list is empty. |
MoveNext () | Boolean | Sets the internal pointer in the ColumnView to the next line. True is returned if the move cannot be executed. |
Remove (Key As String) | ~ | Removes the row with the key' Key' from the ColumnView control. |
Table 17.5.0.2.1: Selected methods of the ColumnView class
The Add (…) method inserts a new row into the ColumnView:
Add ( Key As String, Text As String [ , Picture As Picture, Parent As String, After As String ] ) As _TreeView_Item
To understand the properties, methods, and events of the ColumnView control, you need to understand the (virtual) _TreeView class, because the ColumnView is basically a _TreeView that has been added to the source code to manage columns that are already available in _TreeView. To increase confusion, _TreeView is internally a GridView - a grid of cells into which you can insert text and images. However, you cannot freely access these cells from a _TreeView. The reason for this is that a single _TreeView row is an entire *row* in the GridView.
Example: By calling the Add method:
ColumnView.Add("1", "Text erste Spalte", pibIcon1)
create a new line - identified by the key “1” - to which the text “Text first column” and a preceding icon are added in the only (first) column. Since the return value of the add method is a _TreeView_Item object, you can use this object to specify the texts of other ColumnView columns, but without an image of the type Picture, if required:
ColumnView.Add("1", "Text erste Spalte")[1] = "Text zweite Spalte der 1. Zeile" ColumnView.Add("1", "Text erste Spalte")[2] = "Text dritte Spalte der 1. Zeile"
For example, an alternative to creating a row of a ColumnView with several columns is not to use the return value of the add method directly, but to save it in a variable of the data type _TreeView_Item and to continue working with this variable:
Dim hItem As _TreeView_Item hItem = ColumnView.Add("1", "Text erste Spalte", pibIcon1) hItem[1] = "Text zweite Spalte der 1. Zeile" hItem[2] = "Text dritte Spalte der 1. Zeile"
Another approach with a double indexing offers alternative 2:
ColumnView.Add("1", "Text erste Spalte", pibIcon1) ColumnView[1][1] = "Text zweite Spalte der 1. Zeile" ColumnView[1][2] = "Text dritte Spalte der 1. Zeile"
The special treatment of the first column in a row (row) of a ColumnView compared to the other columns requires getting used to, especially since only the first column can be assigned an image.
The ColumnView class has the following events, among others:
Event | Description |
---|---|
_Click () | The event is triggered when clicking on a row in the ColumnView. |
_Activate () | This event is triggered when double-clicking on a row in the ColumnView. |
_Select () | The event is triggered if the selection of the rows in a ColumnView has changed. |
Table 17.5.0.3.1: Selected events of the ColumnView class
The following table contains some information about selected properties of the GridView, TableView and ColumnsView controls to help you select the grid for your projects:
The ColumnView class has the following events, among others:
Event | GridView | TableView | ColumnView |
---|---|---|---|
Header? | x | x | x |
Editable cells? | ~ | x | x |
Multi-selection possible? | x | x | x |
Icons can be displayed in cells? | x | x | Only 1st column |
Text in cells individually formatted? | x | x | ~ |
Accessing data with a key? | ~ | - | x |
Display grid? | x | x | ~ |
Grid can be switched off? | x | x | - |
Table 17.5.0.4.1: Selected properties of GridView, TableView and ColumnsView
Articles