|
-
Sep 17th, 2009, 08:44 AM
#1
Thread Starter
Fanatic Member
listview column
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")
-
Sep 17th, 2009, 08:53 AM
#2
Re: listview column
You can use the autoresize method
lsvOrderDetails.AutoResizeColumn(...
lsvOrderDetails.AutoResizeColumns(...
-
Sep 17th, 2009, 09:10 AM
#3
Frenzied Member
Re: listview column
well i am not sure, but doesn't using index help
-
Sep 17th, 2009, 09:22 AM
#4
Thread Starter
Fanatic Member
Re: listview column
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
Code:
lsvOrderDetails.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize)
but then this is not as good for the contents
Code:
lsvOrderDetails.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent)
-
Sep 17th, 2009, 09:26 AM
#5
Re: listview column
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?
-
Sep 17th, 2009, 09:33 AM
#6
Thread Starter
Fanatic Member
Re: listview column
 Originally Posted by Negative0
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.
 Originally Posted by Negative0
the Add Method returns a column object, which you can then use to reference the column.
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
Last edited by MrtforCode; Sep 17th, 2009 at 09:38 AM.
-
Sep 17th, 2009, 09:40 AM
#7
Re: listview column
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)
-
Sep 17th, 2009, 09:41 AM
#8
Re: listview column
And for the resize to work properly, you need to call it after the data has been added to the listview.
-
Sep 17th, 2009, 09:44 AM
#9
Thread Starter
Fanatic Member
Re: listview column
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)
-
Sep 17th, 2009, 09:47 AM
#10
Thread Starter
Fanatic Member
Re: listview column
 Originally Posted by Negative0
And for the resize to work properly, you need to call it after the data has been added to the listview.
right that could be the cause, give me a few minutes I ll check
Thanks
-
Sep 17th, 2009, 09:53 AM
#11
Thread Starter
Fanatic Member
Re: listview column
ok, that was the case, now I see it works fine with this:
Code:
lsvOrderDetails.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent)
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) 
will have to work this out
Last edited by MrtforCode; Sep 17th, 2009 at 09:57 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|