views:

111

answers:

1

Ok, so having given up on getting the built in .NET configuration system to save/load data about a custom object per user, I have moved to using a serializable object. And, to go a step further, I'd like to bind it to my controls in the options window of my application.

Please forgive the length of this question as it has some chunks of code in it...

First, the parent object:

[Serializable]
public class ConnectionSettings
{
    public List<Connection> Connections { get; set; }

    public ConnectionSettings()
    {
        Connections = new List<Connection>();
    }
}

Because there will be multiple connections that will be saved, I figured this would be the easiest way to store them.

A chunk of the Connection object:

[Serializable]
public class Connection : NotifyBase
{
    private string hostName;
    [DisplayName( "Host Name" )]
    public string HostName
    {
        get { return hostName; }
        set { SetField( ref hostName, value, "HostName" ); }
    }

    /* Other field snipped for your sanity,*/
    /* same format as host name */

    public List<string> Channels { get; set; }

    public Connection()
    {
        Channels = new List<string>();
    }
}

For a general idea of how the form looks like: I have a ComboBox that will display the Host Name of all the saved connections, when the user selects a Host Name, it will populate the other fields on the form with their respective values. I realize this shouldn't be so hard, but for some reason, I can't get the combo box portion working, and the more I think about it, I'm not sure If I know how to know which particular connection to populate the other controls with...

more info The problem is, I'm not sure how to bind everything that needs binding. I was going off of this example. What I'd like to be able to do is for every Connection object in the deserialized ConnectionSettings (from a file) display the host name in the combo box, and when you select a host name, it fill in the rest of the related data to the other controls on the form.

Any help ill be greatly appreciated.

A: 

Ok, I think I've figured it out. I changed the ConnectionSettings to inherit List and it seems to be working correctly.

Justin Drury