How to preserve settings in a listview?

B

Bob Landers

I finally have all my files showing up in a listview control.

At the moment, I have two columns showing - one for file names and another
for "date created". When my form pops up these two columns are very close
together. Naturally, I adjust the size of the columns and off I go.
However, when I open the form again, the adjustments I made to the column
sizes have not been preserved. Is there a way to do this?



TIA
Bob
 
P

Peter Hibbs

Bob.

I assume you are talking about the Visual Basic 6.0 ListView control
(in MSCOMCTL.OCX).

I have not used this control myself in Access but according to the
Microsoft Visual Basic 6.0 Controls Reference book you can set the
width of a column using the ColumnHeaders.Add method (which is an
optional parameter). The syntax is something like :-

ListView1.ColumnHeaders.Add(index,key,text,width,alignment,icon)

You could set the width of your two columns (presumably in twips) when
you set up the control initially. I am not sure if there is any way to
read back the width of a column if the user subsequently changes it,
however, which may be a problem if you need that option.

Alternatively, you might consider using a Flex Grid control which can
change column widths dynamically, it would depend on how you are using
the ListView control. See this Web site for a demo of using the Flex
Grid control.

http://www.rogersaccesslibrary.com/Otherdownload.asp?SampleName='Flex Grid Demo.mdb'

Peter Hibbs.
 
B

Bob Landers

Thank to both of you.

I've managed to set the initial width of the columns. I was looking for a
solution that enabled any subsequent changed by the user to be preserved -
eg to increase the width of one column etc - so that the new column widths
became the default widths when the listview was invoked again.



Regards
Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top