【发布时间】:2020-05-21 07:43:42
【问题描述】:
我和我的好友 Xylophone 已经在这方面工作了好几个小时,但无法弄清楚这一点,我们将不胜感激。我基本上是在尝试读取该 URL 中的所有文本并搜索关键字。
if (comboBoxEdit1.Text == "Hello")
{
label2.Text = "Current Status: Searching...";
this.dataGridView3.ScrollBars = ScrollBars.None;
this.dataGridView3.MouseWheel += new MouseEventHandler(mousewheel);
dataGridView3.Rows.Clear();
string line;
int row = 0;
List<String> LinesFound = new List<string>();
StreamReader file = new StreamReader("https://pastebin.com/raw/fWxKdRjN");
while ((line = file.ReadLine()) != null)
{
if (line.Contains(textEdit1.Text))
{
string[] Columns = line.Split(':');
dataGridView3.Rows.Add(line);
for (int i = 0; i < Columns.Length; i++)
{
dataGridView3[i, row].Value = Columns[i];
}
row++;
label2.Text = "Current Status: " + dataGridView3.Rows.Count + " Matche(s) Found";
}
else if (dataGridView3.RowCount == 0)
{
label2.Text = "Current Status: No Matche(s) Found";
}
}
}
【问题讨论】:
-
另外补充一下,它只读取原始文本的第一行。
-
我已经回答了你,你的代码有多个问题,导致多个问题。如果您不能使用我的答案,我认为您需要让您的问题更加集中,否则我最终会为您编写明确的解决方案。