Answer the question
In order to leave comments, you need to log in
How to change title of WinForm c#?
I have 2 forms, when I clicked a button in the first form (Form2), the name of another form (Form1) was changed
Code in Form1
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace FormName
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
Form2 st = new Form2();
st.Show();
}
public static void name(string name){
this.Text = name;
}
}
}
using System;
using System.Drawing;
using System.Windows.Forms;
namespace FormName
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
void Button1Click(object sender, EventArgs e)
{
if(textBox1.Text != null) MainForm.name(textBox1.Text);
}
}
}
Answer the question
In order to leave comments, you need to log in
public static void name(string name){
this.Text = name;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question