我正在开发一个带有多个编辑器窗口的 winforms html 编辑器,因为每个编辑器窗口都将写入数据库字段。
我正在将编辑器窗口创建为一个控制数组,并希望在其上方只有一个工具栏,可以根据我当前所在的窗口处理诸如应用粗体、斜体等事件。不幸的是,显然,工具栏上的事件不知道控件之前选择了什么。
有没有办法做到这一点,或者我应该向每个编辑器窗口添加一个 onenter 事件并静态存储最后使用的编辑器窗口。
I am working on a winforms html editor with multiple editor windows as each editor window will be written to a database field.
I am creating the editor windows as a control array and was hoping to just have one toolbar above them that would handle the events such as apply bold, italic... based on the window I was currently in. Unfortunately obviously the event handler of an event on the toolbar doesn't know what the control selected before it was.
Is there a way to get this or should I be adding an onenter event to each editor window and storing statically the last editor window used.
发布评论
评论(2)
我认为存储窗口、HTML 编辑器控件甚至只是一个索引是最简单的选择。
I think that storing the windows, the HTML editor control or even just an index is the simplest option.
我不熟悉你提到的事件类型,而且我可能遗漏了一些东西,但在 WinForms 开发中,触发事件并提供有关发送者和事件的信息是很常见的,符合 EventHandler 委托?
这就是 System.Windows.Forms.Control 的方式.点击进行操作。
您能否遵循此示例,其中
sender
在每种情况下都是编辑器窗口?I'm not familiar with the types of events you mention, and I'm probably missing something, but it's common in WinForms development to have events fire and provide information about the sender as well as the event, conforming to the EventHandler delegate?
This is how System.Windows.Forms.Control.Click operates.
Could you follow this example, where
sender
would be the editor window in each case?