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