Hi,

I think the problem in your sample is InsertColumn.

InsertColumn (strHeading, [nFormat = DT_CENTER|DT_VCENTER|DT_SINGLELINE],
[nColumn = -1]) => return icol

You set

Laurent.

>
> I am trying to use Grid.pm to display rows after rows
> of data I retrieve from a DB2 database.  The problem is
> that I don't know how many rows I am going to be
> displaying ahead of time I need to do it dynamically.
> So I declare teh grid like this:
>
> my $Grid = $W->AddGrid (
>       -name    => "Grid",
>       -pos     => [70,80],
>       -width => 890,
>       -height => 490,
>       -editable => 0,
> ) or die "new Grid";
> $Grid->Hide;
>
> And much later.  I create the output headings, ie the
> very first rows of the database has the column names of
> the databae table.  as in.
> SECTIONA
> --------
>   # codes to extract fieldnames(ie columns) from DB2
>   # blah blah blah.
>
>   # now enter those field names into Grid
>   my $i=0;
>   $Grid->InsertRow($fieldnames[$i],$i);
>   for( $icol = $i++; $icol <= $#fieldnames; $icol++ ) {
>     $Grid->InsertColumn($fieldnames[$icol],$icol);
>   }
>
> SECTIONB
> --------
>   Then I start reading in from the database into an
> array @arraydata each loop I would read in a row of
> data into @arraydata and I then try to insert into the
> grid this row using the following methods.  IT DOES NOT
> WORK!!
>
>   my $rowcnt=1;
>   while( @arrayData = $sth->fetchrow_array() ) {
>        $node_name = shift @arrayData;
>        my $subitemcnt=1;
>        $Grid->InsertRow($node_name,$rowcnt);
>        foreach my $fieldData (@arrayData) {
>
> $Grid->SetCellText($rowcnt,$subitemcnt,$fieldData);
>          $Grid->Refresh();
>          $subitemcnt++;
>        }
>        $rowcnt++;
>   } # endwhile
>
> The only things that gets displayed is just one single
> row from the sectionA of the codes above.  SEction B
> data doesn't seem to get displayed at all :(
> What is the trick to doing dynamic data with Grid?
> What am I doing wrong?? :(

<<attachment: test7.zip>>

Reply via email to