Helen:

Here's some working code you can build on. A subclassing of ListCtrl.

#! /home/xxxx/CitrusPerl/perl/bin/perl # wxPerl Virtual list control test # Created by: HelenCR # Last Modified: March 14,2013 by James M. Lynes, Jr. package MyForm; use strict; use warnings; use Wx qw[:everything]; use base 'Wx::Frame'; sub new { my $class = shift; my $self = $class->SUPER::new( undef, -1, 'Phone book', [ 200, 20 +0 ], wxDefaultSize); my $panel = Wx::Panel->new($self, -1, wxDefaultPosition, wxDefault +Size); $self->{list_ctrl} = MyListCtrl->new($panel); my $sizer = Wx::BoxSizer->new(wxVERTICAL); $sizer->Add( $self->{list_ctrl}, 0, wxALL | wxEXPAND, 5 ); $panel->SetSizer($sizer); return $self; } package MyListCtrl; # Subclass ListCtrl to allow use of a Virtual List Control and a custo +m OnGetItemText Subroutine use strict; use warnings; use base qw(Wx::ListCtrl); use Wx qw(:everything); sub new { my( $class, $parent ) = @_; my $self = $class->SUPER::new( $parent, -1, wxDefaultPosition, wxD +efaultSize, wxBORDER_SUNKEN | wxLC_REPORT | wxL +C_VIRTUAL | wxLC_HRULES ); $self->InsertColumn( 0, 'Last Name' ); $self->InsertColumn( 1, 'First Name' ); $self->InsertColumn( 2, 'Addr City' ); $self->InsertColumn( 3, 'Addr State' ); $self->SetItemCount( 1000 ); return $self; } sub OnGetItemText { print "Entered OnGetItemText\n"; my ($line, $column, $data_item); my ($self, $item, $col) = @_; $data_item = 'test'; return $data_item; } my $app = Wx::SimpleApp->new; my $frame = MyForm->new; $frame->Show(1); $app->MainLoop;

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.