|
-
Apr 22nd, 2004, 02:48 AM
#1
Custom dialog
I have a problem with my code...
VB Code:
Public Class frmViewEditBoundary
Inherits System.Windows.Forms.Form
'some code omitted for clarity
'constructor
Public Sub New(ByVal data As Boundary)
MyBase.New()
InitializeComponent()
itsBoundary = data
End Sub
Public Shadows Function ShowDialog(ByRef owner As IWin32Window) As Boundary
MyBase.ShowDialog(owner) 'call the base class version and ignore its return value
Return DialogResult 'return our own data
End Function
Public Shadows Property DialogResult() As Boundary
Get
Return itsDialogResult
End Get
Set(ByVal Value As Boundary)
itsDialogResult = Value
End Set
End Property
'other code omitted for clarity
Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
DialogResult = Nothing
Me.Close()
End Sub
Private Sub cmdOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOK.Click
DialogResult = itsBoundary
Me.Close()
End Sub
End Class
What it should do:
A Boundary object is passed in when declaring a NEW frmViewEditBoundary instance. This boundary's data is examined and displayed in the form's controls. This part works OK. But when the user has finished viewing or editing the data he clicks either OK or CANCEL to close the form.
If OK is clicked then the boundary object is returned via the DialogResult property that I have shadowed to use class Boundary as its data type. It should be returned regardless of any changes made.
If CANCEL is clicked then the value NOTHING is passed back instead.
However, the problem is that no matter which button I hit the boundary is passed back. Why is this? The code for the buttons is right at the bottom of the class block above.
Have I shadowed the 2 things properly (DialogResult and ShowDialog())?
Any ideas?
Thanks,
Adam.
Last edited by wossname; Apr 22nd, 2004 at 03:36 AM.
I don't live here any more.
-
Apr 22nd, 2004, 11:38 AM
#2
Fanatic Member
Place a break point on your cancel event and make sure that the code is stepping into the shadowed DialogResult property. I dont think it is. I think it is possible that the code is treating your frmViewEditBoundary class strictly as a System.Windows.Forms.Form and it is therefore not running the shadowed DialogResult property.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|