
c# listbox 右键删除菜单进行删除该项的事件,还要把txt文本里的内容同步删除,因为我每次listbox加载的
c#listbox右键删除菜单进行删除该项的remove事件,还要把txt文本里的内容同步删除,因为我每次listbox加载的txt文本里的内容,麻烦有高手请教下!!...
c# listbox 右键删除菜单进行删除该项的remove事件,还要把txt文本里的内容同步删除,因为我每次listbox加载的txt文本里的内容,麻烦有高手请教下!!
展开
展开全部
添加:using System.IO;
private void 菜单名(object sender, MouseEventArgs e)
{
if ( listBox1.SelectedIndex<0) return;
listBox1.Items.RemoveAt(listBox1.SelectedIndex);
StreamWriter sw = new StreamWriter("c:\a.txt",false);
foreach (string item in listBox1.Items)
{
sw.WriteLine(item);
}
sw.Close;
sw.Dispose();
}
把代码区的粘贴到你的删除事件中即可。
private void 菜单名(object sender, MouseEventArgs e)
{
if ( listBox1.SelectedIndex<0) return;
listBox1.Items.RemoveAt(listBox1.SelectedIndex);
StreamWriter sw = new StreamWriter("c:\a.txt",false);
foreach (string item in listBox1.Items)
{
sw.WriteLine(item);
}
sw.Close;
sw.Dispose();
}
把代码区的粘贴到你的删除事件中即可。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询