Hello, how to refer to a column created in code for a listview, I need to set it's width property but don't know how to refer to it in code.
Code:lsvOrderDetails.Columns.Clear()
lsvOrderDetails.Columns.Add("Product")
Printable View
Hello, how to refer to a column created in code for a listview, I need to set it's width property but don't know how to refer to it in code.
Code:lsvOrderDetails.Columns.Clear()
lsvOrderDetails.Columns.Add("Product")
You can use the autoresize method
lsvOrderDetails.AutoResizeColumn(...
lsvOrderDetails.AutoResizeColumns(...
well i am not sure, but doesn't using index help
I am close but not perfect, works for the headers fine, but not for the contents (cells) of the columns.
I tried this, works fine for the headers
but then this is not as good for the contentsCode:lsvOrderDetails.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize)
Code:lsvOrderDetails.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent)
To answer your initial question, the Add Method returns a column object, which you can then use to reference the column.
What issue are you having with the resize based on column content?
I need the content of the listview columns to be fully displayed.
I bet it does, I mean I knew it should, but where can I see it, so I would know how to call it
or alternatively can I please get an example on how to get the index of the listview columns
thanks
Since it returns a value, you can assign it to a variable:
Code:Dim c As ColumnHeader
c = ListView1.Columns.Add("hello")
c.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent)
And for the resize to work properly, you need to call it after the data has been added to the listview.
do you know how to resize all of the columnheaders of the listview, I tried this, it should be something similar pointed to the cells or else...
Code:lsvOrderDetails.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent)
ok, that was the case, now I see it works fine with this:
but I'll still have to adjust the columns that columnsContents is taking less space than the headers, I guess there is no function that would do the both (headers and the contents) :)Code:lsvOrderDetails.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent)
will have to work this out