Dee J. Doena
Dee J. Doena

Reputation: 1843

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?

Upvotes: 3

Views: 20062

Answers (5)

Muhammad Suliman
Muhammad Suliman

Reputation: 1

set HorizontalExtent = 0 and set HorizontalScrollbar = true.

Upvotes: 0

Ismail Gunes
Ismail Gunes

Reputation: 558

It's no sense and annoying as told by Sriram Sakthivel but it's not impossible

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

Upvotes: 0

Coder Panda
Coder Panda

Reputation: 668

Could this be what you are looking for?

It uses the HorizontalExtent property.

Upvotes: 0

BJladu4
BJladu4

Reputation: 273

You should use listbox.HorizontalScrollbar = true;

Upvotes: 3

Sriram Sakthivel
Sriram Sakthivel

Reputation: 73462

listbox.HorizontalScrollbar = true;

Upvotes: 12

Related Questions