动态更改标签文本 [英] Change label text dynamically

查看:102
本文介绍了动态更改标签文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果第一个标签显示访问权限,我想更改标签文本,但是当我运行程序时它不起作用...



任何人都可以帮助

 if(Access.Text ==Lollies)
{
PgeTitle.Text =Sweets;
}





我尝试过:



 if(Access.Text ==Lollies)
{
PgeTitle.Text = String.Format(Sweets);
}

解决方案

如果没有关于这种情况的更多信息,就很难说为什么代码未按预期运行。



为了调查(任何)情况,掌握使用调试器至关重要。尝试在不同的代码行上放置断点,研究变量的值等。这样,您将学习如何查看程序流及其行为的原因。



作为起点,请看开始使用调试器 - Visual Studio | Microsoft Docs [ ^ ]

I want to change the label text if the first label says access, but its not working when i run the program...

can anyone help

if (Access.Text == "Lollies")
{
    PgeTitle.Text = "Sweets";
}



What I have tried:

if (Access.Text == "Lollies")
{
    PgeTitle.Text = String.Format("Sweets");
}

解决方案

Without having a lot more information about the situation it's quite impossible to say why the code isn't running as expected.

In order to investigate (any) situation, it's critical to master using the debugger. Try placing breakpoints on different code lines, investigate the values of the variables etc. This way you learn how to see the program flow and why it behaves as it does.

As a starting point, have a look at Get started with the debugger - Visual Studio | Microsoft Docs[^]


这篇关于动态更改标签文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆