水平滚动条未显示在我的文本框中 [英] Horizontal scrollbar not showing on my textbox

查看:197
本文介绍了水平滚动条未显示在我的文本框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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;

即使自动换行设置为false,也是如此. (我的文本框在组框中).

请问有什么想法吗?

非常感谢:)

此致

解决方案

您需要执行以下操作才能获得水平滚动条以在Windows窗体文本框中显示:

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

然后可以调整文本框的大小以显示一行.您需要启用Multiline,否则文本框的高度将被设置为文本高度(我似乎找不到一种简单的方法来覆盖它),因此您将无法看到滚动条./p>

On a Winform C# application, i display a textbox on my form. This textbox will display one line, just one. I would like to show and be abe to use an horizontal scrollbar.

I set the property "scrollbar" to horizontal : ScrollBar doesn't show. I add WordWrap to false : ScrollBar doesn't show. I add MultiLine to true ( even if one ligne ) : ScrollBar doesn't show.

My line displayed is a loter "longer" than the 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 at false, it's the same result. ( My textbox is in a groupbox).

Any idea please ?

Thanks a lot :)

Regards,

解决方案

You need to do the following to get a horizontal scroll bar to display in a windows forms 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 give the appearance of one line. You need to have Multiline enabled otherwise the height of the text box will be set to the text height (I can't seem to find an easy way to override this), hence you not being able to see the scroll bar.

这篇关于水平滚动条未显示在我的文本框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆