2013-07-05 25 views
8

ScrolledForm 's scrollBar może czasami powodować problemy. Mam taki sam problem z this guy in EclipseZone Forum (to pytanie zadane w 2005 roku, ale wydaje się być nierozwiązane).Jak wyłączyć pasek przewijania w ScrolledForm?

//The scrollbar should only be displayed in the TreeViewer,not the whole form The scrollbar should only be displayed in the TreeViewer,not the whole form.

+1

Więc nie używaj scrolledform. Użyj innego pojemnika. – jarodeells

+1

@jarodeells to dlatego, że metoda ManagedForm 'getForm()' zwraca ScrolledForm. (Http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi% 2Forg% 2Feclipse% 2Fui% 2Fforms% 2FManagedForm.html) –

+1

Czy byłeś w stanie rozwiązać swój problem za pomocą przykładu @ janhink? Mam to, co wydaje się być tym samym problemem, ale nie jestem w stanie sprawić, aby to rozwiązanie działało, więc znalazłeś takie, które mnie interesuje, jak to działało. – NealSr

Odpowiedz

3

ja się spotkałem tego problemu kilka razy i rozwiązać go tak:

@Override 
protected void createFormContent(IManagedForm managedForm) { 
    // set the form's body's layout to GridLayout 
    final Composite body = managedForm.getForm().getBody(); 
    body.setLayout(new GridLayout()); 

    // create the composite which should not have the scrollbar and set its layout data 
    // to GridData with width and height hints equal to the size of the form's body 
    final Composite notScrolledComposite = managedForm.getToolkit().createComposite(body); 
    final GridData gdata = GridDataFactory.fillDefaults() 
      .grab(true, true) 
      .hint(body.getClientArea().width, body.getClientArea().height) 
      .create(); 
    notScrolledComposite.setLayoutData(gdata); 

    // add resize listener so the composite's width and height hints are updates when 
    // the form's body resizes 
    body.addControlListener(new ControlAdapter() { 
     @Override 
     public void controlResized(ControlEvent e) { 
      super.controlResized(e); 
      gdata.widthHint = body.getClientArea().width; 
      gdata.heightHint = body.getClientArea().height; 
      notScrolledComposite.layout(true); 
     } 
    }); 
} 

Zawiadomienie GridLayout w organizmie formularza, a następnie ustawiając szerokość i wysokość hint do kompozytowy: GridLayoutData.

Zwróć także uwagę na zmianę rozmiaru obiektu nasłuchującego na ciele, który aktualizuje dane układu siatki i układy kompozytowe.

Mam nadzieję, że pomoże!

+0

Dziękujemy za próbkę kodu. Próbowałem użyć notScrolledComposite jako rodzica Composite dla mojego SashForm i zamiast usunąć pasek przewijania po prawej stronie, cała kontrola wewnętrzna znika. Czy musisz zrobić coś specjalnego, kiedy użyłeś tej poprawki? – NealSr

+0

Ustawiłeś odpowiedni układ dla notScrolledComposite? – janhink