How to close a dialog window

I think this is a simple question just not finding the right answer.

I have an application that leverages containers that have a few simple controls. Depending on what the user needs to view they will click a menu option. This will cause DialogWindow to appear. The window will show a list of jobs in a listbox, Refresh button to refersh the data if it has changed and a cancle button to close the dialog window.

All work fine except the cancel button. I have tried various ways to close the dialog window to no luck.
I can put the button in the DialogWindow itself to execute a self.close that is not desirable for my needs. I need to do this from within the container control itself. Below is the code to fshow the DialogWindow and I am sure its simple to do.

Thanks, in advanced.

Var dialog As New DialogWindow
Var tc As New JobsList //Container that has a Listbox, refersh and close button

dialog.Width = 1040
dialog.Height = 500
dialog.Title = Main.cbx_Companies.SelectedRowText + " Job Listing"
dialog.HasCloseButton = False
dialog.HasFullScreenButton = False
dialog.HasMaximizeButton = False
dialog.HasMinimizeButton = False
tc.EmbedWithin(dialog, 20, 20, 1000,400)

If Not tc.get_Jobs Then
MessageBox(“Error getting jobs”)
Return False

End If

'txt_Status.Text = dialog.SelectedName
Return True

in the cancelbutton.pressed event insert : self.close
and it should work.

you could define a event and raise it that it appear in the parent.
try AddHandler/RemoveHandler if you add things at runtime.

or memory the object you added in a property to access it later. (Dependency injection)

a screenshot of what it looks like would be helpful.

What would that look like? If I raised the event in the window that pops up how is that translated into a close?

If you see the image the
Refresh button updates the rows works fine.
Close should close the whole window currently can get that to happen
Cancel will close the window and is what I want the close button to do. coded as self.close

Everything inside and including the grey boarder is a container. What is the equivalent of self.close for the cancel button.


I answered my own question “window.close”.

1 Like

for other uses
the container control can use define and raise events and because you create it at runtime you need AddHandler/RemoveHandler for the button action.
in the parent you have a method which is called then.

The container is ‘self’ in the context of the Close button.
To close the whole window (you may have worked this out already), you need to get the parent of the container and close that.
Probably self.parent.close

1 Like