Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / March 2008

Tip: Looking for answers? Try searching our database.

vb 2005    and simple way to wright listview and all its propities to file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John - 04 Mar 2008 15:19 GMT
Hi not sure were to post this but would appreciate if someone knows
simple answer...... which usually never exists

hi have added all my items subitmes and colors etc to my listview1 in
vb 2005

is there a simple way to save the whole object to file
instead of iterating though each property

such as

 Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

       FileSystem.FileOpen(1, "j:\test\lvobj.txt", OpenMode.Output,
OpenAccess.Write, OpenShare.Shared)
           
Write(1, obj.ToString)

       FileClose(1)

   End Sub

then    read it  in at program start

dim  the file  as a  listview1
and it would have all my items and subitems and colors, you know
something simple

PS isn't there something magical  like saveobj(.....................)
I know i'm dreaming

thanks in advance
rowe_newsgroups - 04 Mar 2008 16:31 GMT
> Hi not sure were to post this but would appreciate if someone knows
> simple answer...... which usually never exists
[quoted text clipped - 29 lines]
>
> thanks in advance

I'm not sure if the listview is serializable or not, but if it is you
can just serialize it to xml or a few different formats. You should be
able to find some serialization examples on google or in the ng
archives, just try to adapt those to the listview. If the listview
cannot be serialized, than you might be able to just save the
datasource to a file and restore the listview from there. Datasets and
datatables expose a SaveXml() and LoadXml() method that you can use
for this.

Thanks,

Seth Rowe [MVP]
Cor Ligthert[MVP] - 04 Mar 2008 17:56 GMT
Hi Seth,

I thought that I was learning something new today about dataset.

I know that it has methods WriteXML and ReadXML, or you should mean a trip
as going from Texas to New Orleans passing Amsterdam.

http://msdn2.microsoft.com/en-us/library/system.data.dataset_members(VS.71).aspx

:-)

Cor

>> Hi not sure were to post this but would appreciate if someone knows
>> simple answer...... which usually never exists
[quoted text clipped - 42 lines]
>
> Seth Rowe [MVP]
rowe_newsgroups - 04 Mar 2008 18:24 GMT
On Mar 4, 12:56 pm, "Cor Ligthert[MVP]" <notmyfirstn...@planet.nl>
wrote:
> Hi Seth,
>
[quoted text clipped - 55 lines]
>
> > Seth Rowe [MVP]

Read / Write or Save / Load, it's all the same to me!

:-)

Thanks,

Seth Rowe [MVP]
John - 04 Mar 2008 20:40 GMT
>On Mar 4, 12:56 pm, "Cor Ligthert[MVP]" <notmyfirstn...@planet.nl>
>wrote:
[quoted text clipped - 65 lines]
>
>Seth Rowe [MVP]

but just writing , such as

dim

       FileSystem.FileOpen(1, "j:\test\lvobj", OpenMode.Output,
OpenAccess.Write, OpenShare.Shared)

Write(1, listview1.ToString)

does not work , do u know what i'm getting out

lets say u for x = 0 to 19 through and put 20 items out and each item
is a valuue of  x and lets say you put 20 different colors out based
on x as well....

I can for eaxh item in listview1.items and put this out for each item
and color

what i'm asking is there an easy way of just writing the object or the
control in one output without iterarting through

Thanks
rowe_newsgroups - 05 Mar 2008 00:14 GMT
> On Tue, 4 Mar 2008 10:24:53 -0800 (PST), rowe_newsgroups
>
[quoted text clipped - 93 lines]
>
> - Show quoted text -

The closest thing I could think of was serialization, which is
dramatically different than just calling .ToString() with a
filestream. I did a quick test just now and it seems that the listview
cannot be directly serialized, so your best bet is to either inherits
from the listview and implement your own serialization handler (a
large, painstaking task) or to serialize the datasource of the
listview as mentioned above.

Thanks,

Seth Rowe [MVP]
kimiraikkonen - 04 Mar 2008 16:38 GMT
> Hi not sure were to post this but would appreciate if someone knows
> simple answer...... which usually never exists
[quoted text clipped - 29 lines]
>
> thanks in advance

Hi,
I'm not familiar with listview at the moment, but here is a code that
saves all the items of a "listbox" into a text file:

Dim myArray(Me.ListBox1.Items.Count - 1) As Object
Me.ListBox1.Items.CopyTo(myArray, 0)
Dim Data As String = Join(myArray, Environment.NewLine)
My.Computer.FileSystem.WriteAllText("c:\test.txt", Data, False)

Sorry, it's not listview control, but it might give you idea to
manipulate the same thing for listview control.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.