Hi,

I suggest to use wx::ListView
It's nearly the same as wx::ListCtrl, but you can easyer seach selected items.

Here's a sample, copy, paste and run:

----------------------------------------------- start sample 
-----------------------------------------------------

#!/usr/bin/perl -w
use strict;
use warnings;

use Wx;

#----------------- Frame ------------------

package MyFrame;

use base qw(Wx::Frame);

use Wx qw ( wxCLOSE_BOX wxSYSTEM_MENU wxCAPTION wxCLIP_CHILDREN wxLC_REPORT 
wxLIGHT_GREY);

my $self;


sub new {
    my $ref = shift;
    my $title = "My App";

    $self = $ref->SUPER::new( undef, -1, "$title", [50,50], [300, 200],
                                wxCLOSE_BOX | wxSYSTEM_MENU | wxCAPTION | 
wxCLIP_CHILDREN
                            );


    my $panel = Wx::Panel->new( $self,  -1);
    my $head = Wx::StaticText->new( $panel,-1,'My ListView: ',[10, 15],[-1, 
-1]);

    my $myListView = Wx::ListView->new( $panel,-1,[10, 40],[280, 
120],wxLC_REPORT);

    #Array with header information
    my @items = ("Name", "City", "Country");

    foreach (0 .. $#items) {
        $myListView -> InsertColumn( $_, $items[$_] );
    }

    #Array with comma seprated items
    my @lines = ("Carl,New York,USA", "Maria,Buenos Aires,Brazil", 
"Kryztina,Zagreb,Croatia");

    foreach my $line (0 .. $#lines) {

        my @items = split(/,/, $lines[$line]);
        my $row = 0; #first row

        my $idx = $myListView -> InsertStringItem( $row, $items[0]); #insert 
the first item at the first line and row

        for $row (1 .. $#items) {
           $myListView -> SetItem( $idx, $row, $items[$row] ); #insert the 
other items
        }

        $myListView -> SetItemBackgroundColour( $idx, wxLIGHT_GREY) if ($line % 
2); #make every second line gray
    }

    return $self;
}



########################## Package MyWindow ####################################

package MyWindow; 
use base qw(Wx::App);

sub OnInit {
  my $frame = MyFrame->new;
  $frame->Show( 1 );
}


package main;
my $wxobj = MyWindow->new();
$wxobj->MainLoop;


------------------------------------- end sample 
---------------------------------------------------

It is also a good idea to look at the wxperl_demo.pl


Regards Daniel








----- Ursprüngliche Mail ----
Von: Erik Colson <[EMAIL PROTECTED]>
An: [email protected]
Gesendet: Mittwoch, den 9. Juli 2008, 07:45:15 Uhr
Betreff: listctrl

Hello,

I'm fairly new to wxperl and trying to create a listctrl with multiple rows.

If I do this:
aListCtrl->InsertStringItem($row++,$_);
in a loop,

it will create those items next to each order.
However, I'd like to have the items listed on separate rows.
How can I achieve this ?

Thanks

-- 
Erik Colson

http://www.ecocode.net


      __________________________________________________________
Gesendet von Yahoo! Mail.
Dem pfiffigeren Posteingang.
http://de.overview.mail.yahoo.com

Reply via email to