Link to home
Start Free TrialLog in
Avatar of jxharding
jxharding

asked on

can i change app.config file so that value of key changes when MenuItem gets checked / unchecked

hi , this is my key in the app.config file
<add key="AppendTextBoolean" value="True" />

this is how i read it
Dim bConcatenateOutput As Boolean = System.Configuration.ConfigurationSettings.AppSettings("AppendTextBoolean")


this is the Menu_click event
Private Sub mnuAppendToOutput_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuAppendToOutput.Click
        If mnuAppendToOutput.Checked = True Then
            mnuAppendToOutput.Checked = False
            System.Configuration.ConfigurationSettings.AppSettings("AppendTextBoolean") = "False"
        Else
            mnuAppendToOutput.Checked = True
            System.Configuration.ConfigurationSettings.AppSettings("AppendTextBoolean") = "True"
        End If

    End Sub



can i set the value of the Key to to change, because currently it says it is read only when i try to run the above code
thanks
Avatar of RonaldBiemans
RonaldBiemans

Hi Jxharding how are you?

yes you can,

something like

dim ds as new dataset

ds.ReadXml(Application.StartupPath & "\yourexename.exe.config")
ds.Tables(1).Rows(0).Item(1) = "False"
ASKER CERTIFIED SOLUTION
Avatar of RonaldBiemans
RonaldBiemans

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jxharding

ASKER

hi ronald, i'm doing great thanks!


is there an easy way perhaps of reading the value when the application starts?
because currently i'll prob have to read it into a dataset, then make a dataview,sort it / filter it
locate the key i need e.g. MyBoolean , and then set the menu item to checked or not.

thanks for the help!
please ignore last comment from myself, it was really stupid of myself. i haven't done this in a while.

thanks for the help again!