|
|
|
Here's a simple but effective trick to ensure that the column of a ListView control is wide enough to display the entire string you're assigning to the column title or to an element. Just drop a Label on the form, set its Autosize property to True and Visible property to False. Also, ensure that the Label control has a Font property that matches the one used for the ListView.
Then, when you want to ensure that a string will be displayed correctly in the ListView, just assign it to the Label control first, and then compare the Label's Width property with the width of the ListView column: |
Click here to copy the following block | Dim text As String
text = "A very long string added to the ListView" Label1.Caption = text & " "
If ListView1.ColumnHeaders(1).Width < Label1.Width Then ListView1.ColumnHeaders(1).Width = Label1.Width End If ListView1.ListItems.Add , , text |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|