3 Replies - 9364 Views - Last Post: 20 April 2009 - 08:37 AM Rate Topic: -----

#1 dragonseyeangie  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 41
  • Joined: 20-October 08

help adding items to my.settings

Post icon  Posted 19 April 2009 - 12:19 PM

I am trying to create a program that allows the user to add a series of items to 4 different user collection settings.

here's what i have


Private Sub Button1_Click(ByVal sender As System.Object, ByVal	 e	  As System.EventArgs) Handles Button1.Click


		Dim strItemOne As String
		Dim strItemTwo As String
		Dim strItemThree As String
		Dim strItemFour As String

		strItemOne = TextBox1.Text
		strItemTwo = TextBox2.Text
		strItemThree = TextBox3.Text
		strItemFour = TextBox4.Text

		My.Settings.CollectionOne.Add(strItemOne.ToString)
		My.Settings.CollectionTwo.Add(strItemTwo.ToString)
		My.Settings.CollectionThree.Add(strItemThree.ToString)
		My.Settings.CollectionFour.Add(strItemFour.ToString)




I keep getting an "Object reference not set to an instance of an object." exception. What am I doing wrong?

Is This A Good Question/Topic? 0
  • +

Replies To: help adding items to my.settings

#2 Core  Icon User is offline

  • using System.Linq;
  • member icon

Reputation: 774
  • View blog
  • Posts: 5,097
  • Joined: 08-December 08

Re: help adding items to my.settings

Posted 19 April 2009 - 12:28 PM

First of all, you have to make sure that CollectionOne, CollectionTwo, CollectionThree and CollectionFour do exist in the Settings list.

Take a look here on how to create settings:
http://msdn.microsof...ze8(VS.80).aspx
Was This Post Helpful? 0
  • +
  • -

#3 dragonseyeangie  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 41
  • Joined: 20-October 08

Re: help adding items to my.settings

Posted 19 April 2009 - 02:49 PM

View PostCore, on 19 Apr, 2009 - 11:28 AM, said:

First of all, you have to make sure that CollectionOne, CollectionTwo, CollectionThree and CollectionFour do exist in the Settings list.

Take a look here on how to create settings:
http://msdn.microsof...ze8(VS.80).aspx


ok i have that problem fixed now how would i add the second group of items as sub items to the first group and add to a list view

here's what i have so far

Dim lstCollection As ListViewItem = New ListViewItem()

		For Each item As String In My.Settings.CollectionOne
			For Each item2 As String In My.Settings.CollectionTwo

				lstCollection.Text = item.ToString
				lstCollection.SubItems.Add(item2.ToString)
				ListView1.Items.Add(lstCollection)

			Next



what am i doing wrong?

This post has been edited by dragonseyeangie: 19 April 2009 - 02:50 PM

Was This Post Helpful? 0
  • +
  • -

#4 LemonMan  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 15
  • View blog
  • Posts: 170
  • Joined: 22-August 05

Re: help adding items to my.settings

Posted 20 April 2009 - 08:37 AM

Make sure you save your settings after you update them:

My.Settings.Save



and reload them when your application starts up:

My.Settings.Load


Was This Post Helpful? 1

Page 1 of 1