i can write listbox in ini file, but i can't write ini file in listbox :S
this code write only one index
string dosyadan = ini.Read("Liste","0");
listBox1.Items.Add(dosyadan.ToString());
I have a problem for ini File
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Cenk Isik42 pointsPosted Jul 29, 2012, 11:51 PM EDT
Moses Spencer20 pointsPosted Mar 1, 2015, 11:52 PM EST
For example let's say you have something like the following "Sample.ini" content:
[ListBoxItems]
ListBoxItem = Value 1.
ListBoxItem = Value 2.
ListBoxItem = Value 3.
You can read it into a ListBox controle like this:
private void btnLoad_Click(object sender, EventArgs e) { IniFile file = new IniFile(); file.Load("Sample.ini"); IniSection listBoxSection = file.Sections["ListBoxItems"]; this.listBox1.Items.Clear(); this.listBox1.BeginUpdate(); foreach (var key in listBoxSection.Keys) this.listBox1.Items.Add(key.Value); listBox1.EndUpdate(); }private void btnSave_Click(object sender, EventArgs e) { IniFile file = new IniFile(); file.Load("Sample.ini"); IniSection listBoxSection = file.Sections["ListBoxItems"]; listBoxSection.Keys.Clear(); foreach (var item in this.listBox1.Items) listBoxSection.Keys.Add("ListBoxItem", item.ToString()); file.Save("Sample.ini"); }