473,322 Members | 1,408 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

ListView and Registry Key

Hi! How can i save all ListView items into registry key with Multistring
type and then extract them again and add to ListView?
Jan 15 '07 #1
1 1529
Not a great example but you'll get the idea

You will need to add your own error trapping

Import Microsoft.Win32

In Sub New add this:

SetupListView()

Add a Listview (ListView1) & 5 buttons:

Private Sub SetupListView()
With ListView1
.Columns.Add("Test Column", 100, HorizontalAlignment.Left)
.View = View.Details
End With
End Sub

Private Sub ClearListView()
ListView1.Items.Clear()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim strItems() As String = {"One", "Two", "Three", "Four", "Five"}
For Each strItem As String In strItems
ListView1.Items.Add(strItem)
Next
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
ClearListView()
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim strItem As String
Dim i As Integer
For i = 0 To ListView1.Items.Count - 1
strItem += ListView1.Items(i).Text
strItem += ";"
Next
strItem = strItem.TrimEnd(";")
Dim reg As RegistryKey =
Registry.CurrentUser.CreateSubKey("Software\Test")
reg.SetValue("Items", strItem)
If Not reg Is Nothing Then reg.Close()
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
ClearListView()
Dim reg As RegistryKey =
Registry.CurrentUser.OpenSubKey("Software\Test", False)
Dim strItems As String = reg.GetValue("Items", "")
Dim strParts() As String = strItems.Split(";")
For i As Integer = 0 To strParts.GetUpperBound(0)
ListView1.Items.Add(strParts(i))
Next
If Not reg Is Nothing Then reg.Close()
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click
Application.Exit()
End Sub

I hope this helps,

Newbie Coder
Jan 15 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Anushya | last post by:
Hi I am using Listview and inherited listview control overriding WndProc & PreProcessMessage in ListView. I need this to customize listview to display only the page the user scrolls to. Since i...
0
by: keith | last post by:
In a ListView control (two columns), I added a few ListView items. ListView listview=new ListView(); listview.Parent=this; listview.View=View.Details; listview.Columns.Add...
7
by: Dave Y | last post by:
I am a newbie to C# and am having trouble trying to override a ListView property method. I have created a new class derived from the Forms.Listview and I cannot figure out the syntax to override...
1
by: Víctor | last post by:
I'm doing a kind of file explorer with some additional funcionalities. The problem is that I'm not able to draw file extension icons in a ListView. I know how obtain icons, but when I try to draw...
3
by: J M | last post by:
When you set the Listview's property AllowColumnReorder to True, users can reorder the columns (quite logical I guess)... Bus how on earth can I obtain from code what order these columns are in???...
7
by: BobAchgill | last post by:
I am trying to decide which of these controls to use to implement letting my user select a full row from MyList. The MyList has several columns which would be nice to sort by at run time. The...
0
by: Jon | last post by:
I am using the AllowColumnReorder property on the listview for my users' convenience...however I need to know what's the recommended method for saving that column order (In VB 6 I saved the order...
0
by: Laserson | last post by:
Hi! How can i save ListView items to file or to registry and then load those items again? For example in Delphi there is so command as WriteComponent...
4
by: Brian Gaze | last post by:
I have created a ListView control and have bound this to a datasource. Within the ItemTemplate of the ListView I have added another ListViewControl which is databound in the code behind. The idea...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.