views:

252

answers:

2

Hi,

I want to save the last selected value in a combobox that displays the data of a DB column, I've tried to save it as a text property but it doesn't work.

what can i do?

thanks in advanced.

EDIT:

The code generated in the settings.settings file is like this:

    [global::System.Configuration.UserScopedSettingAttribute()]
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    [global::System.Configuration.DefaultSettingValueAttribute("")]
    public string TC {
        get {
            return ((string)(this["TC"]));
        }
        set {
            this["TC"] = value;
        }

and the code generated in XML in the app.config file is like this:

        <setting name="TC" serializeAs="String">
            <value />
        </setting>

and it loads the settings by:

this.comboBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text", global::Calc_tisa.Properties.Settings.Default, "TC", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));

I'm wondering if there is a way to change de value on the XML file to the last ValueMember selected in the combobox.

A: 

well nobody answered this question but I found something that works nice.

http://www.codeproject.com/KB/dotnet/Custom_settings_class_cs.aspx

Hope that this works for anyone else.

Ricardo
A: 

What I would do in this case is to create an event handler for FormClosing and update the XML file with the last value the user selected inside there.

transmogrify