所以我有一个名为 fontsettings 的表单,它应该设置 Form1 文本框的字体,但它不会将数据从一个表单传递到另一个表单。这是代码:
private void button1_Click(object sender, EventArgs e)
{
// font family
if (comboBox1.Equals("Arial"))
{
family = "Arial";
}
else if (comboBox1.Equals("Calibri")) {
family = "Calibri";
}
if (comboBox2.Equals(1)) {
size = 1;
}
else if (comboBox2.Equals(2)) {
size = 2;
}
if (comboBox3.Equals("Black")) {
color = "Black";
}
else if (comboBox3.Equals("White")) {
color = "White";
}
Form1 form1 = new Form1();
form1.insertFont(family, size, color);
这是Form1的insertFont方法
public void insertFont(string a, int b, string c)
{
if (textBox1.SelectionLength > 0)
{
xx = textBox1.SelectedText;
textBox1.SelectedText = textBox1.SelectedText.Replace(xx, "<font family=\"" + a + "\" size=\"" + b + "\" color=\"" + c + "\">" + xx + "</font>");
}
else
{
textBox1.Paste("<font family=\"" + a + "\" size=\"" + b + "\" color=\"" + c + "\"></font>");
}
}
什么都没有发生,有人知道我做错了什么吗?