Where is the "Width" property of ListView?

BenTam 1,781 Reputation points
2023-09-06T04:30:17.7466667+00:00

Hello everybody,

I see the following statement on Microsoft Learn's web pages.

If you set a ListView column's width to -1, it automatically resizes to fit the data it contains

Where is the "Width" property of ListView?

NoWidth

NoColumnWidth

Developer technologies C#
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2023-09-06T07:11:25.4533333+00:00

    Hi @BenTam-3003 ,Welcome to Microsoft Q&A,

    According to the documentation of ColumnHeader.Width Property explain:

    This property enables you to set the Width of the ColumnHeader. The ColumnHeader can be set to adjust at run time to the column contents or heading. To adjust the width of the longest item in the column, set the Width property to -1. To autosize to the width of the column heading, set the Width property to -2.

    AS:ListView.Columns[0].Width = -1

    User's image

    For the designer, modify it directly as follows:

    enter image description here

    enter image description here

    Best Regards,

    Jiale


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.