[Gtk-sharp-list] Accessing data from one window by another

Brad Taylor brad@getcoded.net
Mon, 15 Nov 2004 21:24:56 -0800

Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

On Mon, 2004-11-15 at 23:52 -0500, Ryan wrote:
> I don't know if the subject is quite but here goes
> If I have Window1 open then the user wants to do something in WizardWindo=
> When the user finishes enter the data and clicks ok how can I get the=20
> TreeView widget
> in Window1 to refresh (either appending or deleting the item)

The way I would do it would be to make WizardWindow its own class.  Move
all the code that deals with it into that class and set up an event in
WizardWindow that will be raised when the user completes the assistant.
For example:

public class Window1
	public void ShowWizard()
		WizardWindow w =3D new WizardWindow();

		w.Finished +=3D new FinishedHandler(WizardFinishedCb);
	private void WizardFinisihedCb(object o, EventArgs args)
		// update tree view

public delegate void FinishedHandler(object o, EventArgs args);

public class WizardWindow
	public event FinishedHandler Finished;

	public WizardWindow()
		// Set up the window
		Button FinishButton =3D new Button("Finish");
		FinishButton.Clicked +=3D new

	public void Show()
		// Show the window

	public void FinishButtonClickedCb(object o, EventArgs args)
		// destroy the window

		// raise the event
		if(Finished !=3D null)
			Finished(this, new EventArgs());

Let me know if you need any clarification on this code.


Brad Taylor
Genome Software LLC

Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

Version: GnuPG v1.2.5 (GNU/Linux)