简体   繁体   English

如何使列表框水平滚动

[英]How to make a listbox scroll horizontally

I have a listbox that contains a long string.我有一个包含长字符串的列表框。

The beginning is not all that relevant for the user which is why I'd like to make the listbox scroll automatically programatically to the right.开始对用户来说并不是那么重要,这就是为什么我想让列表框以编程方式自动向右滚动。

You can scroll to the last item vertically but I've not yet found a way to simulate the user scroll to the right.您可以垂直滚动到最后一项,但我还没有找到模拟用户向右滚动的方法。

Any ideas?有任何想法吗?

listbox.HorizontalScrollbar = true;

你应该使用listbox.HorizontalScrollbar = true;

Could this be what you are looking for? 可能是你想要的吗?

It uses the HorizontalExtent property. 它使用Horizo​​ntalExtent属性。

It's no sense and annoying as told by Sriram Sakthivel but it's not impossible 按照Sriram Sakthivel的说法,没有任何意义和烦恼,但这并非不可能

        var point = Font.Size ;
        string Mystr = "Gimme all your lovin', all your hugs and kisses too";
        if (point * Mystr.Length > listBox1.Width)
            listBox1.RightToLeft = RightToLeft.Yes;
        listBox1.Items.Add(Mystr);

It will show you automatically end of the string in list box 它会自动显示列表框中字符串的结尾

And connect this method to click property in listbox for getting again in left 并连接此方法以单击列表框中的属性以再次在左侧

private void gotoleft(object sender, EventArgs e)
{
    listbox1.RightToLeft = RightToLeft.No;
}

set HorizontalExtent = 0 and set HorizontalScrollbar = true.设置 HorizontalExtent = 0 并设置 HorizontalScrollbar = true。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM