Where is the "Width" property of ListView?

BenTam 1,541 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

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,192 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jiale Xue - MSFT 30,581 Reputation points Microsoft Vendor
    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