简体   繁体   English

移动父表单的事件

[英]Move Event for Parent Form

I'm working on adding some functionality and fixing some bugs in this code I found here: http://www.c-sharpcorner.com/uploadfile/a644fc/multicolumn-combobox-with-configurable-display-and-value-members-and-fast-search-functionality/ 我正在努力添加一些功能并修复我在此处找到的代码中的一些错误: http//www.c-sharpcorner.com/uploadfile/a644fc/multicolumn-combobox-with-configurable-display-and-value-members -和快速搜索的功能/

One issue is that the grid attached to the textbox stays in the same position on the screen when you move the window. 一个问题是当您移动窗口时,附加到文本框的网格在屏幕上保持相同的位置。 I'm trying to fix this by hiding the grid whenever the parent form is moved. 我试图通过在移动父窗体时隐藏网格来解决这个问题。 In the MultiColumnComboBox class file, I'm using this line of code 在MultiColumnComboBox类文件中,我正在使用这行代码

 this.Parent.Move += new System.EventHandler(this.parent_Move); 

to add my function, parent_Move in the parent's move event. 在父移动事件中添加我的函数parent_Move。 The issue is that Parent is always null. 问题是Parent始终为null。 Is there any way to add to the parent's move event from the class file? 有没有办法从类文件中添加父移动事件? Or is there any other way to determine if the parent form's screen location changed? 或者有没有其他方法来确定父窗体的屏幕位置是否发生了变化? I'm planning on using this control a lot and would prefer to find a way to fix the issue in the class rather than in each file where I would call it. 我打算大量使用这个控件,并希望找到一种方法来解决类中的问题,而不是在我称之为的每个文件中。 Thank you guys for any help you can give me. 谢谢你们给我任何帮助。

如果this.Parent总是为null,那么这个答案对你有帮助: 从用户控件访问父控件 - C#

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM