C# 从文本框中获取文本 vscode
C# get text from textbox vscode
我正在用 C# 构建一个脚本,我想从文本框中获取文本,但这并不顺利,我不知道如何获取文本...
public class Form1 : Form
{
private TextBox textBox1;
public void FormLayout()
{
this.Name = "Form1";
this.Text = "Form1";
this.textBox1 = new TextBox();
this.Size = new System.Drawing.Size(200, 200);
this.StartPosition = FormStartPosition.CenterScreen;
this.Controls.Add(this.textBox1);
string lingua = this.textBox1.Text;
}
}
public class RegisterScriptMenu
{
public static Form1 form = new Form1();
[STAThread]
static void Main()
{
form.FormLayout();;
Application.Run(form);
return form.FormLayout().lingua;
}
[DeclareAction("Exporta_Traduzir")]
public void MyFunctionAsAction1()
{
string linguagem = Main();```
这到底不是returns“linguagem”作为我在文本框中输入的字符串。
我是 c# 的新手,所以也许这很简单,我只是不知道...
首先,Main 是无效的 - 这意味着您不能 return 一个值。其次,你有两个;在你的 form.formLayout()
尝试修复此问题并检查它是否有效,只需尝试创建一个 Label 以查看是否获得值。
public class Form1 : Form
{
private TextBox textBox1;
private Label label1;
public void FormLayout()
{
this.Name = "Form1";
this.Text = "Form1";
this.textBox1 = new TextBox();
this.Size = new System.Drawing.Size(200, 200);
this.StartPosition = FormStartPosition.CenterScreen;
this.Controls.Add(this.textBox1);
string lingua = this.textBox1.Text;
}
}
public class RegisterScriptMenu
{
public static Form1 form = new Form1();
[STAThread]
static void Main()
{
form.FormLayout();
form.label1.Text = form.ligua;
Application.Run(form);
}
[DeclareAction("Exporta_Traduzir")]
public void MyFunctionAsAction1()
{
string linguagem = Main();
我正在用 C# 构建一个脚本,我想从文本框中获取文本,但这并不顺利,我不知道如何获取文本...
public class Form1 : Form
{
private TextBox textBox1;
public void FormLayout()
{
this.Name = "Form1";
this.Text = "Form1";
this.textBox1 = new TextBox();
this.Size = new System.Drawing.Size(200, 200);
this.StartPosition = FormStartPosition.CenterScreen;
this.Controls.Add(this.textBox1);
string lingua = this.textBox1.Text;
}
}
public class RegisterScriptMenu
{
public static Form1 form = new Form1();
[STAThread]
static void Main()
{
form.FormLayout();;
Application.Run(form);
return form.FormLayout().lingua;
}
[DeclareAction("Exporta_Traduzir")]
public void MyFunctionAsAction1()
{
string linguagem = Main();```
这到底不是returns“linguagem”作为我在文本框中输入的字符串。 我是 c# 的新手,所以也许这很简单,我只是不知道...
首先,Main 是无效的 - 这意味着您不能 return 一个值。其次,你有两个;在你的 form.formLayout()
尝试修复此问题并检查它是否有效,只需尝试创建一个 Label 以查看是否获得值。
public class Form1 : Form
{
private TextBox textBox1;
private Label label1;
public void FormLayout()
{
this.Name = "Form1";
this.Text = "Form1";
this.textBox1 = new TextBox();
this.Size = new System.Drawing.Size(200, 200);
this.StartPosition = FormStartPosition.CenterScreen;
this.Controls.Add(this.textBox1);
string lingua = this.textBox1.Text;
}
}
public class RegisterScriptMenu
{
public static Form1 form = new Form1();
[STAThread]
static void Main()
{
form.FormLayout();
form.label1.Text = form.ligua;
Application.Run(form);
}
[DeclareAction("Exporta_Traduzir")]
public void MyFunctionAsAction1()
{
string linguagem = Main();