本文介绍了鼠标悬停在事件上时如何在MDI chlid窗体中找到控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MDI Child表单中有十个按钮序列。当我将cusor一个按钮移动到另一个按钮时,我想在MDI子窗体中的按钮控制下找到当前的cusor。我使用方法

I have ten button sequence in MDI Child form . When i move the cusor one button to another , i want to find current cusor under button control in MDI child form . I use the method

form.PointToClient(point)

但找不到按钮控件

我该怎么办。我无法找到控件,因为它是MDI的孩子。主要是好的。



我尝试了什么:



主要是好吧,但我不能用Mdi子形式。

but not found button control
how can i do . i cannot found the control because it is MDI child . Main is OK .

What I have tried:

main is ok , but i cannot in Mdi child form .

推荐答案

public void DoSomething(string controlName) {
    try
    {
        //MessageBox.Show("Mouse HOVER :" + controlName);
        toolStripStatusLabel.Text = controlName;
    }
    catch (Exception ex)
    {
        throw new Exception(ex.ToString());
    }

}





给孩子打电话:



Call the child:

private void openChildFormToolStripMenuItem_Click(object sender, EventArgs e)
{
    try
    {
        var child = new Form1();
        child.MdiParent = this; //Asign this form as parent
        child.Show();
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.ToString());
    }
}







儿童鼠标悬停事件:




Mouse Hover Event in child:

private void button1_MouseHover(object sender, EventArgs e)
{
    try
    {
        /*
         * There is a public method DoSomething in the MDIParent,
         * I send the control name to the method
         */
        ((MDIParent1)MdiParent).DoSomething("Form1 -" + ((Button)sender).Name);
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.ToString());
    }
}


这篇关于鼠标悬停在事件上时如何在MDI chlid窗体中找到控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 05:37