Windows Develop Bookmark and Share   
 index > Windows Forms General > adjusting ColumnHeader width in ListViewControl
 

adjusting ColumnHeader width in ListViewControl

Hi all,

I am working with a ListView control and I am setting the width of all the column headers to -2. This way the column width adjusts to the longest item in the column and the last empty column of the listview gets "hidden". I have only one column header in this listview control. Now, my problem is that when the form containing the listview loads, and if the width of the form is less than the width of the column header (adjusted to the longest item in the column), the items in the colum that are actually longer than the form width, appear with "..." at the end of them, which is ok, but the horizontal scrollbar does not appear... I am not sure how I can fix this. I would like to see that horizontal scrollbar and not to force the user to resize the form to see the rest of the item's text.

Thanks!

Ale

Ale Gos  Thursday, May 11, 2006 2:29 AM

I solved the problem. Some of the items had an imageindex and some of them didnt. So if the longest item was one with no imageindex, the scrollbar was not showing up. Conclusion: if you want images in the listviewitems in a listview control (in details view) but not in all of the listviewitems, then those will have to have a blank image instead of nothing. If you dont associate an imageindex for all of the items, then assigning the columnheader.width with -2, does not behave like it should.

Thanks anyway

Ale Gos  Thursday, May 11, 2006 3:40 PM

I solved the problem. Some of the items had an imageindex and some of them didnt. So if the longest item was one with no imageindex, the scrollbar was not showing up. Conclusion: if you want images in the listviewitems in a listview control (in details view) but not in all of the listviewitems, then those will have to have a blank image instead of nothing. If you dont associate an imageindex for all of the items, then assigning the columnheader.width with -2, does not behave like it should.

Thanks anyway

Ale Gos  Thursday, May 11, 2006 3:40 PM

You can use google to search for other answers

Custom Search

More Threads

• MDIParent/MDIChild Problem
• Filling images in a datagrid dynamically
• Invisible ListBox & ComboBox Items
• help running process continually in background
• Hyperlinks in a Datagrid
• Checking if a directory exists.
• TreeNode handle
• help in coding a game application
• mouse down
• WebBrowser - setting value for "type=file"