Có thể định cấu hình cuộn dọc trong ICSharpCode.TextEditor như vậy theo mặc định không có thanh cuộn dọc có thể nhìn thấy được. Và chỉ khi ai đó gõ rất nhiều dòng (vượt quá chiều cao hiện tại của điều khiển này) thì thanh cuộn dọc xuất hiện tự động. Nếu có, làm thế nào?ICSharpCode.TextEditor Vertical Scrolling
Trả lời
dễ dàng của nó để thêm chức năng bản thân:
1) Chuyển đến không gian tên ICSharpCode.TextEditor
và mở lớp TextAreaControl
. Vị trí tập tin là: C: ... \ ICSharpCode.TextEditor \ Project \ Src \ Gui \ TextAreaControl.cs
2) Thêm một phương pháp để thiết lập sự hiện diện của các thanh cuộn ngang hoặc dọc:
public void ShowScrollBars(Orientation orientation,bool isVisible)
{
if (orientation == Orientation.Vertical)
{
vScrollBar.Visible = isVisible;
}
else
{
hScrollBar.Visible = isVisible;
}
}
3) trong dự án với TextEditor, đây là cách bạn gọi ShowScrollBars()
phương pháp:
editor.ActiveTextAreaControl.ShowScrollBars(Orientation.Vertical,false);
mã này hiện các trick để hiển thị thanh cuộn dọc dựa trên số dòng văn bản:
public TextEditorForm()
{
InitializeComponent();
AddNewTextEditor("New file");
SetSyntaxHighlighting("Mathematica");
editor.ActiveTextAreaControl.TextEditorProperties.IndentationSize = 0;
editor.ActiveTextAreaControl.ShowScrollBars(Orientation.Vertical,false);
editor.TextChanged += new EventHandler(editor_TextChanged);
}
void editor_TextChanged(object sender, EventArgs e)
{
bool isVisible = (editor.ActiveTextAreaControl.GetTotalNumberOfLines > editor.ActiveTextAreaControl.TextArea.TextView.VisibleLineCount);
editor.ActiveTextAreaControl.ShowScrollBars(Orientation.Vertical, isVisible);
}
Trong TextAreaControl:
public int GetTotalNumberOfLines()
{
return this.Document.TotalNumberOfLines;
}
ps Tôi đang sử dụng dự án Code Project ICSharpCode-TextEditor này.
Có thể ẩn thanh cuộn ngang không? Tôi đã kiểm tra mã và các cuộc gọi api, nhưng tôi không thể tìm thấy nó. –
Tôi chưa có mã mở trước mặt mình, mặc dù bạn có thể đặt 'Orientation.Vertical' thành' Orientation.Horizontal' –
cảm ơn, vâng tôi biết nhưng tôi đã đặt câu hỏi sai, tôi muốn biết nếu có một cách để xác định tổng số cột/ký tự tối đa trên một dòng để xem liệu nó có thể tự động ẩn HScrollBar dựa trên logic đó hay không. –
- 1. jquery vertical mousewheel smooth scrolling
- 2. Vertical Scroll in stackpanel
- 3. NSTextField Vertical alignment
- 4. Silverlight Vertical only ScrollViewer?
- 5. Mutiple fragments in vertical Linearlayout
- 6. ảnh vertical-align trong div
- 7. constricting scrolling in core-plot
- 8. CSS bảng td vertical-align text-top
- 9. CSS - vertical-align không làm việc
- 10. Tuỳ chỉnh Android scrollview của Vertical Scrollbar
- 11. ediff-split-window-function horizontal == vertical?
- 12. ListBox, VirtualizingStackPanel và Smooth Scrolling trong WPF
- 13. Java side scrolling trò chơi trên android
- 14. Visual Studio 2010 Kinetic/Smooth Scrolling
- 15. Scrolling/Scrollbar Locks Sau khi Scrolltop Animation
- 16. Turnoff Scrolling trong Angular UI ng-grid?
- 17. android: orientation = "vertical" không hoạt động đối với TabWidget
- 18. TVirtualStringTree và Vertical Scroll không hoạt động đúng cách
- 19. Vertical Aligning - Hộp Flex10 của IE10 không hoạt động
- 20. "vertical-align: middle" không căn chỉnh ở giữa trong Firefox
- 21. vertical center Một hình ảnh mà không biết kích thước
- 22. nội dung Vertical sắp xếp trong Android EditText
- 23. CSS class Vertical text vào giữa hình ảnh
- 24. Làm thế nào để thay đổi nền của UIWebView Scrolling?
- 25. Nâng cao jQuery "Sticky Bottom" và cũng Scrolling Sidebar Issue
- 26. Disable Scrolling Khi bấm vào một liên kết
- 27. Visual Studio 2012 XAML Designer Vertical Split không thể được đặt làm mặc định?
- 28. Webkit bỏ qua vertical-align cho inline-block chứa dòng hộp
- 29. Làm thế nào để có được một TextView trong Android có Horizontal Scrolling và autoscrolled?
- 30. Làm thế nào để đặt AUTO-SCROLLING của JTextArea trong Java GUI?
+1 Không còn tumbleweed :) –