RD>
RD> I'm trying to insert a string into my wxListCtrl like so:
RD>
RD>
RD> wxListItem newItem;
RD> newItem.SetId( count );
RD> newItem.SetColumn( 0 );
RD> newItem.SetText( frameName.c_str() );
RD> newItem.SetMask( wxLIST_MASK_TEXT );
RD> m_frameList->InsertItem( newItem );
I'd use
m_frameList->InsertItem(0, frameName);
which is more clear IMO. And SetMask() is unnecessary anyhow (and so is
.c_str() call). But it should be harmless...
RD> However, I get an assertion that says:
RD>
RD> "m_count should match ListView_GetItemCount"
RD>
RD> ListView_InsertItem(), which is a win32 function called inside of the
RD> MSW implementation of wxListCtrl::InsertItem( wxListItem const& ) is
RD> returning -1, which means failure. I am not sure of the details of why
RD> it is failing.
The assert probably shouldn't be triggered if inserting the item failed
but OTOH this would just hide the real problem. I don't know neither why
does it fail though, as usual trying to reproduce the problem in the
listctrl sample might be useful.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
RD> It seems like one is unable to insert an item into the list control
RD> report view in a matrix-fashion.
No, you can't do this. But your original example didn't show it so I still
don't understand why didn't it work.
RD> I find it unfortunate that the documentation did not state this and I
RD> had to resolve to looking at sample code and trial/error to figure
RD> this out. I really hope you guys can document both InsertItem() and
RD> SetItem() for wxListCtrl more properly to reflect this.
I think the best would be to enhance wxListView which I started writing a
long time ago. wxListCtrl API is IMO hopeless, with or without
documentation.
RD> On Oct 16, 1:49 pm, Vadim Zeitlin <va...@wxwidgets.org> wrote:
RD> > On Fri, 16 Oct 2009 11:39:05 -0700 (PDT) Robert Dailey <rcdai...@gmail.com> wrote:
RD> >
RD> > RD> It seems like one is unable to insert an item into the list control
RD> > RD> report view in a matrix-fashion.
RD> >
RD> > No, you can't do this. But your original example didn't show it so I still
RD> > don't understand why didn't it work.
RD>
RD> My guess is that the Win32 API will fail if you set the ID and
RD> column index at the same time when inserting a new item into the list
RD> control.
Of course it won't but if column is 0 it doesn't count. I.e. this is what
InsertItem(idx, label) does anyhow.
RD> > RD> I find it unfortunate that the documentation did not state this and I
RD> > RD> had to resolve to looking at sample code and trial/error to figure
RD> > RD> this out. I really hope you guys can document both InsertItem() and
RD> > RD> SetItem() for wxListCtrl more properly to reflect this.
RD> >
RD> > I think the best would be to enhance wxListView which I started writing a
RD> > long time ago. wxListCtrl API is IMO hopeless, with or without
RD> > documentation.
RD>
RD> Could you explain why it is hopeless?
Basically because it's a direct copy of MSW API for the control with the
same name which is bad even as C API go and horrible in C++. I really don't
know if it's worth going into the details, I'd believe that the troubles
you have using it yourself would be reason enough. Anyhow, just look at the
few wxListView methods to see what I mean: do you really prefer writing
SetItemState(n, 0, wxLIST_STATE_SELECTED) to Select(n, false)? And so on...