views:

262

answers:

1

I have a Listbox in to which I am binding the data coming from a DataTable

I am using VisualStudio 2003, .net 1.1

    For Each dr As DataRow In dt.Rows            Dim li As New ListItem(dr("BIPAD").ToString().PadRight(25, Microsoft.VisualBasic.ChrW((160))) + dr("TITLENAME").ToString())            lbMagTilteByCategory.Items.Add(li)    
 For Each dr As DataRow In dt.Rows

        Dim li As New ListItem(dr("ID").ToString().PadRight(25, Microsoft.VisualBasic.ChrW((160))) + dr("NAME").ToString()).PadRight(25, Microsoft.VisualBasic.ChrW((160)))+dr("CITY").ToString()

        ListBox.Items.Add(li)

    Next

How can I Set Width for the Columns in ListBox ?.. How can I have Fixed Widths for Columns ??

A: 

Set the ListBox.MultiColumn property to True, and then set the ListBox.ColumnWidth property to whatever size you want it to be.

Alternatively, you could switch to using a ListView control with the View set to Details. The columns in the ListView control are much more intuitive and easier to customize.

Jacob Ewald
Hi, Thanks for the response.. I am using Visual Studio 2003 / .NET 1.1. I don't find MultiColumn Property for LISTBOX
msbyuva
My apologies, I run VS2008 with .Net 3.5 and the property shows up for me. I checked the MSDN website and it lists it as available in your version, but their documentation must be mistaken.http://msdn.microsoft.com/en-us/library/system.windows.forms.listbox_properties%28VS.71%29.aspx
Jacob Ewald
Hi, Thanks for providing me the documentation information. Probably in my version there might be some plugins or updated SP need to be added. I will look in to it, Thanks again !!...
msbyuva