如何在从datagridview删除时删除文本文件的内容
我有一个 datagridview,其中该 datagridview 的内容将来自我的示例文本文件。当我单击加载时,我将获得来自sample.txt的数据,并且该文本文件中的数据显示在datagridview中。我的数据网格视图中将有一个复选框列。如果用户选中,我将选择该行,当用户单击删除按钮时,我想从文本文件中删除该文本。
假设我的文字如下
如果我单击第一行的复选框并单击删除,我想从文本文件中删除该文本
I am having a datagridview where the content of that datagridview will be from my sample text file. When i click on load i will have the data from sample.txt and that data in that text file is shown in the datagridview. I will have a checkbox column in my datagridview. If the user checks i will select the row and when user clicks delete button i would like to delete that text from the text file.
Suppose my text is as follows
If i click on the check box of first row and click on delete i would like to delete that text from text file
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
textfiles - 如何在 C# 中从文本文件中删除一行? - 堆栈...
如何删除一行来自 C# 中的文本文件?
请参阅此链接。
还有我的一些评论在这里。
读取所有行搜索您想要的文本并从列表中删除该文本并将其写入文本文件。
textfiles - How to delete a line from a text file in C#? - Stack ...
How to delete a line from a text file in C#?
See this link .
And some comments from me Here.
Read the all lines search the text u want and delete that text from list and write it in text file.
使用 Text OBDC 或 OLE DB 访问文本文件内容怎么样?
您必须:
使用简单的oledb命令来处理文件中的数据。或者使用数据适配器。
string sql = "DELETE FROM yourFile WHERE ID=" + ID;
ExecuteNonQuery(sql);
How about using the Text OBDC or OLE DB to access the text file contents?
You will have to:
Use simple oledb commands to process the data in file. Or use a data adapter.
string sql = "DELETE FROM yourFile WHERE ID=" + ID;
ExecuteNonQuery(sql);