I suggest you implement Classes, and then bind a ListBox to display links; use serialization to save state.
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Windows.Forms;
namespace WhatEver
[DataContract]
public class LinkData
{
[DataMember]
public bool Visited { set; get; }
[DataMember]
public string LblText { set; get; }
[NonSerialized]
public LinkLabel LnkLabl;
public LinkData()
{
}
public LinkData(string lbltext, bool visited) : this()
{
LblText = lbltext;
Visited = visited;
}
}
[DataContract]
public class LinksData
{
public LinksData()
{
TheLinks = new List<LinkData>();
}
[DataMember]
public List<LinkData> TheLinks { set; get; }
public LinkLabel AddLLabel(string text, bool visited)
{
LinkData newlink = new LinkData(text, visited);
LinkLabel newll = new LinkLabel();
newll.Text = text;
newll.Links.Add(0, text.Length, text);
newlink.LnkLabl = newll;
TheLinks.Add(newlink);
return newll;
}
}
}
You can do something like this to set the LinkLabels in a Panel without manually positioning them:
LinksData lnksdata = new LinksData();
for (int i = 0; i < 10; i++)
{
LinkLabel llbl = lnksdata.AddLLabel("www.somewhere" + i + ".com", false);
llbl.LinkClicked +=
panel1.Controls.Add(llbl);
llbl.Dock = DockStyle.Top;
llbl.BringToFront();
}
Write the serializer and deserializer, and then you can save the entire state of each LinkLabel in one file. Note that since you cannot serialize the LinkLabel Control itself, you will need to re-create them when you de-serialize.