Helen:

I haven't played with a ListCtrl yet, but from my reading, to use a Virtual List Control you can't use ListCtrl directly. You have to subclass ListCtrl into a derived class like MyListCtrl. The derived class will include your OnGetItemText method which will be called instead of the default OnGetItemText method in ListCtrl which is happening now in your test code. Clear as mud yet?

Also wxLC_VIRTUAL can only be used with wxLC_REPORT so your MyListCtrl->new call has to include wxLC_VIRTUAL | wxLC_REPORT. I'm not sure what the 32 does that's in your code.

Example code from wxPerl Demo:

package Wx::DemoModules::wxListCtrl::Virtual; use strict; use base qw(Wx::ListCtrl Wx::DemoModules::wxListCtrl); use Wx qw(:listctrl wxRED wxBLUE wxITALIC_FONT wxDefaultPosition wxDefaultSize); sub new { my( $class, $parent ) = @_; my $self = $class->SUPER::new ( $parent, -1, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_VIRTUAL ); $self->bind_events; $self->create_menu; my( $small, $normal ) = $self->create_image_lists; $self->AssignImageList( $small, wxIMAGE_LIST_SMALL ); $self->AssignImageList( $normal, wxIMAGE_LIST_NORMAL ); $self->InsertColumn( 0, "Column 1" ); $self->InsertColumn( 1, "Column 2" ); $self->InsertColumn( 2, "Column 3" ); $self->InsertColumn( 3, "Column 4" ); $self->InsertColumn( 4, "Column 5" ); $self->SetItemCount( 100000 ); return $self; } sub OnGetItemText { my( $self, $item, $column ) = @_; return "( $item, $column )"; }

Remember that there is code in the wxPerl Demo example that you won't need. It's just there to support the structure of the demo.

James

There's never enough time to do it right, but always enough time to do it over...


In reply to Re: wxPerl virtual list control not calling OnGetItemText? by jmlynesjr
in thread wxPerl virtual list control not calling OnGetItemText? by HelenCr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.