A horizontal scrollbar that does not appear in my text box

In a Winform C # application, I display a text box in my form. This line will display one line, only one. I would like to show and use abe to use the horizontal scrollbar.

I set the scroll bar property to the horizontal position: ScrollBar is not displayed. I add WordWrap to false: ScrollBar is not displayed. I add MultiLine to true (even if one ligne): ScrollBar is not displayed.

My display string is much longer than contrΓ΄le, so I really need a scrollbar :(

Here is the definition:

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; 

Even with wordwrap on false, this is the same result. (My text box is in the group box).

Any idea please?

Many thanks:)

Hi,

+1
source share
2 answers

You need to do the following to get the horizontal scrollbar to display in the windows form text box:

 this.TxtBox_ApercuFichier.Multiline = true; this.TxtBox_ApercuFichier.WordWrap = false; this.TxtBox_ApercuFichier.ScrollBars = System.Windows.Forms.ScrollBars.Horizontal; 

You can then resize the text box to make one line appear. You need to enable Multiline , otherwise the height of the text field will be set to the height of the text (I cannot find an easy way to override this), so you won’t be able to see the scroll bar.

+4
source

The following code determines that the ScrollBar is not displayed, as well as the parent panel in which it is contained.

 HScrollBar hScroller = textBox.HScrollBar; hScroller.Visible = false; hScroller.Parent.Visible=false; 
0
source

Source: https://habr.com/ru/post/912464/


All Articles