0
我一直有这个问题的麻烦,我想我需要学习如何工作,我有FormMain(我的主窗体)和第二个窗体(FormAddUrls)当我打开form2(FormAddUrls)我想要通过multitextbox值返回到主窗体(FormMain)在窗体之间传递txtBox值
我知道在VB中就像说:FormMain.txtBoxUrls.Text = finalOutput;但在C#中并不那么容易。
(Form1上) - FormMain
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Windows.Forms;
using WraithProjectCreator;
using IronPdf;
using System.Text;
namespace GSAProjectCreator
{
public partial class FormMain : Form
{
private IniParser m_Parser = null;
public FormMain()
{
InitializeComponent();
}
private void btnShowUrlsForm_Click(object sender, EventArgs e)
{
FormAddUrls fau = new FormAddUrls();
fau.Show();
}
}
}
(窗口2) - FormAddUrls
using GSAProjectCreator;
using System;
using System.Text;
using System.Windows.Forms;
namespace WraithProjectCreator
{
public partial class FormAddUrls : Form
{
public FormAddUrls()
{
InitializeComponent();
}
private void btnAddUrls_Click(object sender, EventArgs e)
{
StringBuilder builder = new StringBuilder();
builder.Append("{");
foreach (string line in txtBoxURLsMass.Lines)
{
//Helpers.returnMessage(line);
builder.Append(line + "|");
}
builder.Append("}");
string finalOutput = "";
if (builder.ToString().Contains("|}")) {
finalOutput = builder.ToString().Replace("|}", "}");
}
//FormMain.txtBoxUrls.Text = finalOutput;
this.Close();
}
}
}
我已经中省略了很多的Form1的代码留下的基本结构,我试图回传finalOutput从form2到form1(txtBoxUrls.Text)文本框,任何帮助将不胜感激。
谢谢你的帮助。 – colinreedy674