2
How can I make a string in Appsettings, and then use it, for example, the string in Appsettings is this:
string example = "example"
And take the value that’s in the Appsettings string and put it in a textbox, how can I do this?
2
How can I make a string in Appsettings, and then use it, for example, the string in Appsettings is this:
string example = "example"
And take the value that’s in the Appsettings string and put it in a textbox, how can I do this?
2
Only use ConfigurationManager.AppSettings[chave]
.
using System.Configuration;
// outras coisas
public static void AlgumaFuncao()
{
var valor = ConfigurationManager.AppSettings["exemplo"];
meuTextBox.Text = valor.ToString();
}
Remembering that the config of the application needs to look like this
<configuration>
<appSettings>
<add key="exemplo" value="Alguma string de exemplo"/>
</appSettings>
</configuration>
Appsettings["example"] - Not a string ?
0
In his app.config
:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="exemplo" value="exemplo"/>
</appSettings>
</configuration>
In code C#:
string exemplo = System.Configuration.ConfigurationManager.AppSettings["exemplo"];
Remember to add refrence to System.Configuration
0
To put in a txtbox you must do this:
txtbox.text = Properties.Settings.Default.teste;
To save is so:
Properties.Settings.Default.teste = txtbox.Text;
Properties.Settings.Default.Save();
Properties.Settings.Default.Upgrade();
Browser other questions tagged c# winforms
You are not signed in. Login or sign up in order to post.
string test = Configurationmanager.Appsettings["example"] ?
– Denis
In the app.config: <appSettings> <add key="example " value="example"/> </appSettings>
– Denis