gpt4 book ai didi

C#加载文件按钮标签

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

我正在使用 richTextBox1.LoadFile(open.FileName, RichTextBoxStreamType.PlainText); 在文本框中加载文件。

我想做的是逐行加载一个文件,每一行是一个按钮的标签以这种方式有多个按钮,每个按钮来自文件的每一行

我正在使用 C# 和 Visual Studio 2010 Express

最佳答案

这里有一些东西可以让你开始:

 private void Form1_Load(object sender, EventArgs e)
{
int i = 1;
var allLines = File.ReadAllLines(@"c:\temp\test.txt");

foreach (var line in allLines)
{
var b = new Button();
b.Text = line;
b.AutoSize = true;
b.Location = new Point(0, b.Size.Height * i);
this.Controls.Add(b);
i++;
}

}

关于C#加载文件按钮标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5945942/

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