[英]Horizontal scrollbar not showing on my textbox
在Winform C#應用程序上,我在窗體上顯示一個文本框。 此文本框將顯示一行,僅顯示一行。 我想展示一下,並且願意使用水平滾動條。
我將屬性“ scrollbar”設置為水平:滾動條不顯示。 我將WordWrap添加到false:ScrollBar不顯示。 我將MultiLine添加到true(即使是一個ligne):ScrollBar不顯示。
我顯示的行比控制行“更長”,所以我真的需要一個滾動條:(
這是定義:
this.TxtBox_ApercuFichier.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.TxtBox_ApercuFichier.Location = new System.Drawing.Point(11, 30);
this.TxtBox_ApercuFichier.Multiline = true;
this.TxtBox_ApercuFichier.Name = "TxtBox_ApercuFichier";
this.TxtBox_ApercuFichier.ScrollBars = System.Windows.Forms.ScrollBars.Horizontal;
this.TxtBox_ApercuFichier.Size = new System.Drawing.Size(702, 21);
this.TxtBox_ApercuFichier.TabIndex = 12;
即使自動換行為假,結果也是一樣。 (我的文本框在組框中)。
有什么想法嗎?
非常感謝 :)
問候,
您需要執行以下操作以獲取水平滾動條以在Windows窗體文本框中顯示:
this.TxtBox_ApercuFichier.Multiline = true;
this.TxtBox_ApercuFichier.WordWrap = false;
this.TxtBox_ApercuFichier.ScrollBars = System.Windows.Forms.ScrollBars.Horizontal;
然后,您可以調整文本框的大小以顯示一行。 您需要啟用Multiline
否則文本框的高度將被設置為文本高度(我似乎找不到一種簡單的方法來覆蓋它),因此您將無法看到滾動條。
以下代碼將設置ScrollBar以及包含其的父面板不可見。
HScrollBar hScroller = textBox.HScrollBar;
hScroller.Visible = false;
hScroller.Parent.Visible=false;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.