小智 109
要在运行时更改表单的标题,我们可以编写如下代码
public partial class FormMain : Form
{
public FormMain()
{
InitializeComponent();
this.Text = "This Is My Title";
}
}
Run Code Online (Sandbox Code Playgroud)
Alp*_*ine 54
您可以使用该Text属性更改Windows窗体标题栏中的文本.
// This class is added to the namespace containing the Form1 class.
class MainApplication
{
public static void Main()
{
// Instantiate a new instance of Form1.
Form1 f1 = new Form1();
// Display a messagebox. This shows the application
// is running, yet there is nothing shown to the user.
// This is the point at which you customize your form.
System.Windows.Forms.MessageBox.Show("The application "
+ "is running now, but no forms have been shown.");
// Customize the form.
f1.Text = "Running Form";
// Show the instance of the form modally.
f1.ShowDialog();
}
}
Run Code Online (Sandbox Code Playgroud)
包括从Form类创建新对象在内的所有答案都绝对是在创建 new form。但是您可以在类中使用子类的Text属性。例如:ActiveFormForm
public Form1()
{
InitializeComponent();
Form1.ActiveForm.Text = "Your Title";
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
176582 次 |
| 最近记录: |