Setting values in a multicolumn list

You may have noticed that inserting an item using the row methods described earlier only sets the initial column of a multi-column report list. To set the strings in other columns, use the method SetStringltem().

SetStringItem(index, col, label, imageId=-1)

The index and col parameters are the row and column indexes for the cell you are setting. You can set the col parameter to 0 to set the first column, but the index must correspond to a row that already exists in the list control—in other words, you can only use this method on a row that has already been added. The label argument is the text to display in the cell, and the imageld is an index back into the appropriate image list, if you want to display an image in the cell.

The SetStringltem() method is technically a special case of the method Set-Item(info), that takes a wx.Listltem instance. To use this method, set the row, column, and any other parameters on the list item instance before adding it to the list. You can also get the wx.Listltem instance at the cell by using the method Get-Item(index, col=0), which returns the first column of a row by default, but takes the second parameter to allow you to select an item from a different column.

Was this article helpful?

0 0

Post a comment