ListCtrl behaves different than expected ...

hello,

I use '2.8.7.1 (msw-unicode)

I'm using a standard ListCtrl in LC_LIST mode.

I followed the description of chapter 13 from Robin's book.

Setting the columnwidth:
- if I don't specify it, it becomes to large (due to some large strings)
- if I specify the with ( where X can be any number), the column width is fixed to about 40 .. 50
    self.List_Test.SetColumnWidth ( 0, x )

How can I set the columnwidth ?

Getting EVT_LIST_ITEM_ACTIVATED event:
- event.GetImage always returns -1 (although there is a picture in the list item)
- event.GetPoint always returns (0,0)

Is this a bug or is this the assumed behavior ?

Getting EVT_LIST_ITEM_SELECTED event:
- event.GetPoint always returns (0,0)

Is this a bug or is this the assumed behavior ?

thanks,
Stef Mientki

Stef Mientki wrote:

hello,

I use '2.8.7.1 (msw-unicode)

I'm using a standard ListCtrl in LC_LIST mode.

I followed the description of chapter 13 from Robin's book.

Setting the columnwidth:
- if I don't specify it, it becomes to large (due to some large strings)
- if I specify the with ( where X can be any number), the column width is fixed to about 40 .. 50
   self.List_Test.SetColumnWidth ( 0, x )

I think this method only applies to LC_REPORT mode.

How can I set the columnwidth ?

Getting EVT_LIST_ITEM_ACTIVATED event:
- event.GetImage always returns -1 (although there is a picture in the list item)
- event.GetPoint always returns (0,0)

Is this a bug or is this the assumed behavior ?

Getting EVT_LIST_ITEM_SELECTED event:
- event.GetPoint always returns (0,0)

The activated and selected events are not specifically mouse events (even if they happen to be initiated by the mouse) so the point is not set. Instead you can use event.GetIndex() and listCtrl.GetItemRect(index) to find the position of the item in the widget.

I don't think the event image member is ever set, it was probably put there for some ideas that were never implemented.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

Stef Mientki wrote:

hello,

I use '2.8.7.1 (msw-unicode)

I'm using a standard ListCtrl in LC_LIST mode.

I followed the description of chapter 13 from Robin's book.

Setting the columnwidth:
- if I don't specify it, it becomes to large (due to some large strings)
- if I specify the with ( where X can be any number), the column width is fixed to about 40 .. 50
   self.List_Test.SetColumnWidth ( 0, x )

I think this method only applies to LC_REPORT mode.

after playing with it for while,
it seems that it does work,
but you must place it after the last item is added to the listctrl.

How can I set the columnwidth ?

Getting EVT_LIST_ITEM_ACTIVATED event:
- event.GetImage always returns -1 (although there is a picture in the list item)
- event.GetPoint always returns (0,0)

Is this a bug or is this the assumed behavior ?

Getting EVT_LIST_ITEM_SELECTED event:
- event.GetPoint always returns (0,0)

The activated and selected events are not specifically mouse events (even if they happen to be initiated by the mouse) so the point is not set. Instead you can use event.GetIndex() and listCtrl.GetItemRect(index) to find the position of the item in the widget.

I don't think the event image member is ever set, it was probably put there for some ideas that were never implemented.

and HitTest also doesn't work,
so we would better skip paragraph 13.4.3 of your book :wink:

cheers,
Stef

···