How to make a search usercontrol generic in .net2.0 winforms

你。 提交于 2019-12-06 15:14:25

On our project, we did this by adding an ISearchable interface with CanSearch and Search properties. These took a direction argument specifying forwards or backwards, and the Search method also took a string for performing the search and an enumeration specifying the type of matching (start of phrase, end of phrase, included in phrase, etc).

We then implemented this interface on all controls in a hierarchy. Each control then delegated to the child controls as it saw fit. Our container application would contain a textbox and find next/previous buttons. The container would query the first view in the hierarchy for the interface, which would then chain down to the target control as seen fit by each control in the hierarchy.

We implemented an alternative approach for our clipboard operations whereby we checked the actively focused control directly first to see if it supported our ISupportEdit interface. If it did not, we then used the hierarchy approach.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!