请告诉我,当 CAPS_LOCK 键启用时,我如何在StatusStrip中显示。我尝试按照示例进行操作: 一和二,但我的应用程序中没有显示任何内容。我创建了一个新项目,添加了StripStatusLabel元素并尝试将任何信息带入其中。奇怪的是只在初始化方法中获得显示:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
toolStripStatusLabel1.Text = "111";
}
}
但在其他方法中它不起作用。
using System.Diagnostics;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
//toolStripStatusLabel1.Text = "111";
}
public void Form2_KeyDown(object sender, KeyEventArgs e)
{
Debug.Write("123");
toolStripStatusLabel1.Text = "222";
}
}
}
Windows 窗体。NetFramework 4.5 PS 抱歉这个愚蠢的问题 :)
更新: 在此处输入图像描述
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
KeyDown += tst;
}
public void TextBoxTest()
{
textBox1.Text = "onetwo";
}
private void tst(object sender, KeyEventArgs e)
{
if ((e.KeyCode & Keys.KeyCode) == Keys.CapsLock)
{
if (Control.IsKeyLocked(Keys.CapsLock))
toolStripStatusLabel1.Text = "Caps";
}
}
}
}
但是输出不起作用。请告诉我我做错了什么