wxListCtrl

BlitzMax Modules Forums/Brucey's Modules/wxListCtrl

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Me thinks you should rather start afresh and not rely too much on the listctrl sample code.

The problem with the samples is that they tend to show *everything* that a control can do, which is not necessarily what *you* want to do.

Here are some snippets from my current "playing with wxMax" project, SQLiteDBA. It assumes you are using the listctrl in REPORT mode, which is most useful for showing things with rows/columns.

Adding an item to a row in a listctrl (which has several columns)
	Method InsertIntoList(index:Int, list:wxListCtrl)

		Local item:wxListItem = New wxListItem.Create()
		item.SetImage(-1)
		item.SetText(seq)
		item.SetId(index)
		
		list.InsertItem(item)

		item.SetText(name)
		item.SetColumn(1)
		list.SetItem(item)

		item.SetText(Null)
		If unique Then
			item.SetImage(IMG_CHECKED)
		Else
			item.SetImage(IMG_UNCHECKED)
		End If
		item.SetColumn(2)
		list.SetItem(item)

	End Method

SetImage() is telling the item to show a particular image from an image list - obviously an optional thing :-)

When inserting a new row (of more than one column), create a wxListItem object and set it's parts. It's easier. "id" is the row index. User InsertItem() to initially add that row.
For other columns on that row, use SetColumn() on the item to specifiy which column the item is for, and then SetItem() to actually "put" the item in the list at the desired location.


This little snippet sets the column headings :
	Method SetIndexHeadings()
		indexesList.InsertColumn(0, _("Seq"), wxLIST_FORMAT_CENTRE, 60)
		indexesList.InsertColumn(1, _("Name"))
		indexesList.InsertColumn(2, _("Unique"), wxLIST_FORMAT_CENTRE, 80)
	End Method

Note that for a REPORT mode listctl, you'll need column headings. (unless you define the listctrl to hide them).


Hope this helps a bit.