这是最简单的事情,但我无法更新状态栏上的文本......我刚开始在 c# 中工作但找不到解决方案.. 在所有答案中,接受的答案是statusBar1.Text = "text";
我制作了简单的菜单并在菜单中添加了 LOAD 项目。图片已加载,一切正常,只是状态文本没有更新......顺便说一句,MessageBox 还在状态栏中显示我需要的正确文本。这是我的代码,但它不起作用:
private void menuLoad_Click(object sender, EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.Title = "Load Photo";
dlg.Filter = "jpg files (*.jpg)"
+ "|*.jpg|All files (*.*)|*.*";
if (dlg.ShowDialog() == DialogResult.OK)
{
try
{
statusBar1.Text = "Loading " + dlg.FileName;
pbxPhoto.Image = new Bitmap(dlg.OpenFile());
statusBar1.Text = "Loaded " + dlg.FileName;
MessageBox.Show("Text = " + dlg.FileName);
}
catch (Exception ex)
{
statusBar1.Text = "Unable to load file " + dlg.FileName;
MessageBox.Show("Unable to load file: " + ex.Message);
}
}
dlg.Dispose();
}