2013-07-05 37 views
8

ScrolledForm 's scrollBar đôi khi có thể gây ra vấn đề. Tôi đáp ứng cùng một vấn đề với this guy in EclipseZone Forum (đó là một câu hỏi năm 2005 nhưng dường như chưa được giải quyết).Làm thế nào để tắt thanh cuộn trong 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

Vì vậy, không sử dụng biểu mẫu cuộn. Sử dụng một container khác. – jarodeells

+1

@jarodeells đó là do phương thức 'getForm()' của ManagedForm trả về một ScrolledForm. (Http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi% 2Forg% 2Feclipse% 2Fui% 2Fforms% 2FManagedForm.html) –

+1

bạn có thể giải quyết vấn đề của mình bằng ví dụ @ janhink không? Tôi có những gì dường như là cùng một vấn đề nhưng tôi không thể có được giải pháp đó để làm việc, vì vậy nó bạn tìm thấy một trong đó là tôi tò mò những gì nó đã làm cho nó làm việc. – NealSr

Trả lời

3

Tôi đã đi qua vấn đề này nhiều lần và giải quyết nó như thế này:

@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); 
     } 
    }); 
} 

Thông báo các GridLayout trong cơ thể của hình thức và sau đó thiết lập chiều rộng và chiều cao hint đến tổng hợp của GridLayoutData.

Cũng lưu ý trình lắng nghe thay đổi kích thước trên cơ thể cập nhật dữ liệu bố cục lưới và bố cục hỗn hợp.

Hy vọng điều đó sẽ hữu ích!

+0

Cảm ơn bạn đã gửi mẫu mã. Tôi đã cố gắng sử dụng notScrolledComposite làm cha Composite cho SashForm của tôi và thay vì loại bỏ thanh cuộn bên phải, toàn bộ điều khiển bên trong biến mất. Bạn có cần phải làm bất cứ điều gì đặc biệt khi bạn sử dụng bản sửa lỗi này không? – NealSr

+0

Bạn đã đặt bố cục phù hợp cho notScrolledComposite chưa? – janhink

Các vấn đề liên quan