0

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, 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, ChrW(160)) + dr("NAME").ToString()).PadRight(25, ChrW(160)) + dr("CITY").ToString()
        ListBox.Items.Add(li)
    Next
Next

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

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Hi, Thanks for the response.. I am using Visual Studio 2003 / .NET 1.1. I don't find MultiColumn Property for LISTBOX
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. msdn.microsoft.com/en-us/library/…
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 !!...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.