gpt4 book ai didi

c# - 在 Windows 应用程序中显示结果

转载 作者:太空宇宙 更新时间:2023-11-03 23:31:50 25 4
gpt4 key购买 nike

我对如何在 Windows 窗体应用程序中显示结果感到困惑。

private void btnBrowse_Click(object sender, EventArgs e)
{
DialogResult result = openFileDialog1.ShowDialog();
if (result == DialogResult.OK)
{
txtFileName.Text = openFileDialog1.FileName;
}
}

private void btn_search_Click(object sender, EventArgs e)
{

var result = File.ReadAllLines(@txtFileName.Text).Select(s => s.Contains(txt_search.Text));


}

我想将搜索结果显示为列表。谁能帮我?

最佳答案

一种简单的方法是只设置一个文本框,该文本框会在搜索完成后更新。

private void richTextBox1_TextChanged(object sender, EventArgs e)
{
richTextBox1.SelectionStart = richTextBox1.Text.Length; //Set the current caret position at the end
richTextBox1.ScrollToCaret(); //Now scroll it automatically
}

private void btnBrowse_Click(object sender, EventArgs e)
{
DialogResult result = openFileDialog1.ShowDialog();
if (result == DialogResult.OK)
{
txtFileName.Text = openFileDialog1.FileName;
}
}

private void btn_search_Click(object sender, EventArgs e)
{

var result = File.ReadAllLines(@txtFileName.Text).Select(s => s.Contains(txt_search.Text));

this.richTextBox1.AppendText(result.ToString()); //---> Appends the Text to the Rich Text Box, you may want to change the variable result(i hope its not a collection)
}

关于c# - 在 Windows 应用程序中显示结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31918455/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com