c# - 使用用户输入的数字在文本框中查找单词
问题描述
目前正在尝试弄清楚我如何使用用户输入。在我的情况下,在文本框中找到特定的行和单词并复制该信息并将单词输出到新的文本框中是 1/2/3。用户输入的文本框已经被拆分,因此第一个数字选择文本文件以从第二个数字选择一个单词,第三个数字选择一个单词。在读取第一个数字后,所选文本文件将在发现和输出关键字之前输出到富文本框中。
到目前为止,我对此没有太多代码,但我真正不明白的唯一部分是如何找到特定的行和单词。目前,具有三个用户输入的文本框被分解为每个单独的部分,并存储在每个部分的不可见标签中,正如您在我的代码中看到的那样。
到目前为止,这是我的代码:
public partial class Form1 : Form
{
int NumLines;
public Form1()
{
InitializeComponent();
}
private void btnSubmit1_Click(object sender, EventArgs e)
{
var charArray = txtPoemInput.Text.Split('/'); // Dividing the users input into 3 usable sections using invisible labels
lblPoem.Text = charArray[0];
lblLine.Text = charArray[1];
lblWord.Text = charArray[2];
// Testing for which poem is going to be used
if (lblPoem.Text == "1")
{
//Read in text file
}
else if (lblPoem.Text == "2")
{
//Read in text file
}
else if (lblPoem.Text == "3")
{
//Read in text file
}
NumLines = txtPoem.Lines.Count();
// the user input line and word finds and selects the speciic word required
// Displays word in the Keyword box
解决方案
推荐阅读
- django - 具有 GenericRelation 的 QuerySet 返回“NoneType”对象没有属性“startswith”
- reactjs - 如何使用 mui-datatable 在 React 上保持选择
- mysql - MySQL - 连接和之间
- ffmpeg - 将所有文件夹中的所有 .wav 文件转换为 .flac
- docker - 如何在不使用 docker-in-docker 的情况下在 jenkins 管道中使用 docker
- python - 如何解决此唯一约束失败:auth_user.username
- azure-sqldw - 我在 azure SQL DW 中维护库存,并希望使用 T-SQL 计算一天的初始和最终库存。以下是我的详细信息
- python - 检查一个值,如果不满足条件则返回相同的值
- mysql - 如何在表中具有数组字段的列上应用 mysql 连接?
- javascript - 接受连续点的电子邮件的正则表达式