Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [nebula-dev] Lazy initialisation of grid


You need to call setItemCount.  Tell the Grid how many items you want.

Regards,

-Chris


From: "Jonathan Alvarsson" <jonathan.alvarsson@xxxxxxxxx>
To: "Nebula Dev" <nebula-dev@xxxxxxxxxxx>
Date: 08/08/2007 10:58 AM
Subject: Re: [nebula-dev] Lazy initialisation of grid




On 8/8/07, Christopher J Gross <chris.gross@xxxxxxxxxx> wrote:
>  
> Hi Jonathan,
>  
> It works for me.  Can you explain further or provide a reproducible snippet?  Did you pass SWT.VIRTUAL?
>  
> Regards,
> -Chris
>  

Yes here is a snippet of what I am trying to do. Probably I haven't quite figured out how to do it...
The handleEvent method never gets called. Shouldn't it be?

import org.eclipse.nebula.widgets.grid.Grid;
import org.eclipse.nebula.widgets.grid.GridColumn;
import org.eclipse.nebula.widgets.grid.GridItem;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout ;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;

public class VirtualGridWidget {
   public static void main(String... args) {
       Display display = new Display();
       Shell shell = new Shell(display);
       shell.setLayout(new FillLayout());
                     
       Grid grid = new Grid( shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.VIRTUAL | SWT.MULTI );
       grid.setHeaderVisible(true);
       grid.setRowHeaderVisible(true);
       grid.setCellSelectionEnabled(true);
       
       grid.setItemHeight(20);
       for (int i = 0; i < 10; i++) {
           
           GridColumn column = new GridColumn(grid, SWT.NONE);
           column.setText(i + "");
           column.setWidth(40);
       }
       
       grid.addListener( SWT.SetData, new Listener() {
           public void handleEvent(Event event) {
               System.out.println("handleEvent()");
               GridItem item = (GridItem)event.item;
               for (int i = 0; i < 10; i++) {
                   item.setText(i, i + "");
                   item.setHeaderText( ('a'+i) + "" );
               }
           }
       } );
       
       shell.setSize(500, 200);
       shell.open();
       while (!shell.isDisposed()) {
           if (!display.readAndDispatch())
               display.sleep();
       }
       display.dispose();
   }
}
_______________________________________________
nebula-dev mailing list
nebula-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/nebula-dev


Back to the top