如何在 VB.NET 中更新窗口标题文本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18029060/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 14:31:42  来源:igfitidea点击:

How do I Update Window Title text in VB.NET

vb.net

提问by Mr. Price

When you visit Google, IE says something like Google - Microsoft Internet Explorer. However, if you changed the address to, say, Stack Overflow, it would say something like Stack Overflow - Microsoft Internet Explorer.

当您访问 Google 时,IE 会显示类似Google - Microsoft Internet Explorer 的内容。但是,如果您将地址更改为 Stack Overflow,它会显示类似Stack Overflow - Microsoft Internet Explorer 的内容

So, how can I make a dynamic title bar that changes with a variable?

那么,如何制作随变量变化的动态标题栏?

回答by Ken White

You set the Form.Text, using the current instance (which you access using Me):

您设置Form.Text, 使用当前实例(您使用 访问Me):

Dim SomeVariable As String

SomeVariable = "Site 1 - My Application"
Me.Text = SomeVariable

For future reference, you can figure a lot of this out by clicking on the object you want to change things on in the Designerand then looking at the Propertieswindow. In this case, you'd click on your main window and then looking at Properties, where you'd find the "Text" property. Changing it in the Propertieswindow would change it in the Designerimmediately when you type new text and hit the Enterkey or move to another property.

为了将来参考,您可以通过在设计器中单击要更改内容的对象,然后查看“属性”窗口来解决很多问题。在这种情况下,您可以单击主窗口,然后查看Properties,您可以在其中找到“Text”属性。当您键入新文本并按下键或移动到另一个属性时,在“属性”窗口中更改它会立即在设计器中更改它Enter