views:

1016

answers:

2

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.

A: 

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?

[SerializableAttribute]
[ComVisibleAttribute(true)]
public delegate void EventHandler(
    Object sender,
    EventArgs e
)

This is how System.Windows.Forms.Control.Click operates. Could you follow this example, where sender would be the editor window in each case?

Blair Conrad
+1  A: 

I think that storing the windows, the HTML editor control or even just an index is the simplest option.

I went with this, just storing the index of the webbrowser on entry.
PeteT