将文本文件导入datagridview C ++ [英] Import text file into datagridview C++
问题描述
您好,我想点击按钮,将txt文档导入DataGridView。如何实现?
Hello, I want to do when clicking on the button, import the txt document into the DataGridView. How can this be implemented?
Txt文档, 以这种近似方式填写:
Txt document, fill in this approximate way:
1.txt
0,Name0,Test0,Type0
1,Name1,Test1,Type1
1.txt
0, Name0, Test0, Type0
1, Name1, Test1, Type1
DataGridView由4列组成。
DataGridView consists of 4 columns.
我还想知道当你点击其中一行1或2时。在TextBox那里是下载某个文件的链接;
I also wanted to realize that when you click on one of the rows 1 or 2. In the TextBox There is a link to download some file;
我的英文不好,抱歉:)
My english bad, sorry :)
推荐答案
您好,
我搜索了DataGridView,发现它是VB或C#,但不是C ++。所以我只能给你一个工作流程,你应该在VB或C#论坛上提出代码。
I searched for DataGridView and found that it is VB or C#, but not C++. So I can only give you a workflow, for code you should ask in a VB or C# Forum.
open txt file
while (readline(txt file))
{
extract the 4 columns separated by ,
add the columns to DataGridView
}
close txt file
show DataGridView
为了处理DataGridView点击事件,你应该阅读文档DataGridView。
For handling the DataGridView click event, you should read the documentation for DataGridView.
https://social.msdn .microsoft.com /论坛/ zh-CN / home?forum = vbgeneral
https://social.msdn.microsoft.com/Forums/en-us/home?forum=csharpgeneral
< a href ="https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.datagridview?view=netframework-4.7.2"> https://docs.microsoft.com/en -us / dotnet / api / system.windows.forms.datagridview?view = netframework-4.7.2
此致,Guido
这篇关于将文本文件导入datagridview C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!