Thursday, August 18, 2005

wxPython note: how to select many rows in Grid?

This problem puzzled me some time ago, and I forgot the solution again today. Thus I feel it necessary to take it down here.

There is absolutely no way of setting a style like wx.CB_MULTIPLE to specify multiple selection here. wxGrid support multiple row selection by itself, see a reference

http://lists.wxwidgets.org/archive/wx-dev/msg21759.html

The only thing you need to have is specifying the second (hidden!) param of SelectRow - bAppend (I am vague about the name). When it's true you will see the row selected without cleaning other rows.

Of course, this implies that selecting many rows can only be done from program. Thus in order to respond to mouse and keyboard behaviors, event catching and processing are needed. Anyway, it's not uncommon to process events for a grid.

No comments: