469,954 Members | 1,790 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,954 developers. It's quick & easy.

About the listbox control

Hi, All,
I'm using MS.net 2003 and using a windows.forms.listbox control for my
window application but I don't know why the Horizontal Scrollbar could NOT be
shown even if I set HorizontalScrollbar = true. The text info in listbox
already beyond its right edge. How can I see the hidden part info in listbox?

here is a part of codes.

ListBox.ValueMember = XX
ListBox.DisplayMember = XXXX
ListBox.DataSource = objTarget

Is this because I'm using dataSource and displayMember?

Thanks for your help and have a good one

Brian
Nov 22 '05 #1
5 2641
Hi Brian,

It is a little unclear to me what your problem is.
Is the horizontal scrollbar missing, even if you have set HorizontalScrollbar = true?
If so, I am unable to reproduce this problem as for me the scrollbar is showing when a listbox item is wider than the listbox. Also using MS.Net 2003. Tested using a datasource.

If the problem persists, try using a tooltip showing the full line.
On Wed, 18 May 2005 22:53:24 +0200, Brian <Br***@discussions.microsoft.com> wrote:
Hi, All,
I'm using MS.net 2003 and using a windows.forms.listbox control for my
window application but I don't know why the Horizontal Scrollbar could NOT be
shown even if I set HorizontalScrollbar = true. The text info in listbox
already beyond its right edge. How can I see the hidden part info in listbox?

here is a part of codes.

ListBox.ValueMember = XX
ListBox.DisplayMember = XXXX
ListBox.DataSource = objTarget

Is this because I'm using dataSource and displayMember?

Thanks for your help and have a good one

Brian


--
Happy coding!
Morten Wennevik [C# MVP]
Nov 22 '05 #2
Morten, Thank you
Is the horizontal scrollbar missing, even if you have set HorizontalScrollbar = true?


Yes, horizontal scrollbar never be show even if I have set
HorizontalScrollbar = true ( and listbox item is wider than the listbox.) I
don't know why. If I set ScrollAlwaysVisible = true, it still won't work.
it's stronge.

Thanks and have a good day

Brain
Nov 22 '05 #3
Morten,
You told me you tested using a datasource is OK, how did you do that?
If I use ListBox1.Items.Add(" Item is a very large value that requires
scroll bars"), the Horizontal scroll bar works fine. but If I use
ListBox1.ValueMember = "ID"
ListBox1.DataSource = ObjTarge ' this is a collection object
ListBox1.DisplayMember = "Display" ' this is a proprty of the object

the Horizontal scroll bar won't work. Did I miss something?

BTW, .net 2003, this is not tooltip property for listbox. but In VB.6,
listbox has tooltip property. I'm using .Net 2003

Thanks

Brian

Nov 22 '05 #4
Simple DataSource using an ArrayList

ArrayList list = new ArrayList();
list.Add("Hello World, this is a very long line!");

listBox1.DataSource = list;

A more complex DataSource using a DataSet

DataSet ds = new DataSet("MyDataSet");
ds.Tables.Add("MyDataTable");
ds.Tables["MyDataTable"].Columns.Add("MyColumn");
ds.Tables["MyDataTable"].Rows.Add(new object[]{"Hello World, this is a very long line!"});

listBox1.DataSource = ds.Tables["MyDataTable"];
listBox1.DisplayMember = "MyColumn";

As for tooltip. Add a ToolTip to your project. A ToolTip property should then be added at the bottom of the ListBox properties.

You probably need to set it manually based on which item the cursor is currently over, something like

toolTip1.SetToolTip(listBox1, ds.Tables[0].Rows[0][0].ToString());

On Thu, 19 May 2005 19:08:08 +0200, Brian <Br***@discussions.microsoft.com> wrote:
Morten,
You told me you tested using a datasource is OK, how did you do that?
If I use ListBox1.Items.Add(" Item is a very large value that requires
scroll bars"), the Horizontal scroll bar works fine. but If I use
ListBox1.ValueMember = "ID"
ListBox1.DataSource = ObjTarge ' this is a collection object
ListBox1.DisplayMember = "Display" ' this is a proprty of the object

the Horizontal scroll bar won't work. Did I miss something?

BTW, .net 2003, this is not tooltip property for listbox. but In VB.6,
listbox has tooltip property. I'm using .Net 2003

Thanks

Brian


--
Happy coding!
Morten Wennevik [C# MVP]
Nov 22 '05 #5
In C# code I've written using the System.Windows.Forms.ListBox, if the
ListBox.HorizontalExtent property isn't explicitly set to something greater
than zero then your listbox won't display the horizontal scroll bar.

"Brian" wrote:
Hi, All,
I'm using MS.net 2003 and using a windows.forms.listbox control for my
window application but I don't know why the Horizontal Scrollbar could NOT be
shown even if I set HorizontalScrollbar = true. The text info in listbox
already beyond its right edge. How can I see the hidden part info in listbox?

here is a part of codes.

ListBox.ValueMember = XX
ListBox.DisplayMember = XXXX
ListBox.DataSource = objTarget

Is this because I'm using dataSource and displayMember?

Thanks for your help and have a good one

Brian

Nov 22 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Brian | last post: by
2 posts views Thread by SamSpade | last post: by
2 posts views Thread by Luca | last post: by
8 posts views Thread by Oddball | last post: by
6 posts views Thread by Chris Leuty | last post: by
18 posts views Thread by Dave Sauny | last post: by
8 posts views Thread by nirdeshonline | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.