3
如何从文本文件获取值并选择具有该值的复选框?如何从文本文件中获取值并选择具有该值的复选框?
我使用此代码试图让谁是后等于值:
string installerfilename = string.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "installer.ini");
IEnumerable<string> inilines = File.ReadAllLines(installerfilename).AsEnumerable();
string selectedItem = checkedListBox1.SelectedItem.ToString();
bool IsChecked = checkedListBox1.CheckedItems.Contains(selectedItem);
inlines = inlines.Select(line => line == string.Format("product={0}", selectedItem))
? Regex.Replace(line, string.Format("product={0}", selectedItem), string.Format(@"product={0}", selectedItem)) : line);
也是我这个尝试:
foreach (var line in inilines)
{
if (line.Contains("product={0}"))
{
IsChecked = true;
//checkedListBox1.CheckedItems =true;
}
,但我不知道如何从勾选一个CheckedListBox谁拥有相同的行后的值如何product="name of checkbox"
以及我如何做,在文本文件我的产品=全部选中所有复选框? – ben
@ben只要检查第一行,如果第一行是全部,就为所有索引调用SetItemChecked –
@ben,但我不是更好地保存“all”来保存已检查的项目。 –