Sure! Here's a simple program written in C# that displays the class name of a button when the user hovers over it:

using System;
using System.Windows.Forms;

namespace ButtonClassName
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void button1_MouseHover(object sender, EventArgs e)
        {
            Button button = (Button)sender;
            MessageBox.Show($"Class Name: {button.GetType().Name}");
        }
    }
}

To use this program, follow these steps:

  1. Create a new Windows Forms Application project in Visual Studio.
  2. Replace the contents of the MainForm.cs file with the code provided.
  3. Add a button to the form (e.g., button1).
  4. Double-click on the form to generate the InitializeComponent() method.
  5. Build and run the program.

Now, when you hover over the button, a message box will appear displaying its class name

can you write a program in c# so that when user mouseover on any existing buttons it will show its class name

原文地址: http://www.cveoy.top/t/topic/hRjR 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录