Results 1 to 2 of 2

Thread: Custom dialog

  1. #1

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Custom dialog

    I have a problem with my code...

    VB Code:
    1. Public Class frmViewEditBoundary
    2.     Inherits System.Windows.Forms.Form
    3.  
    4. 'some code omitted for clarity
    5.  
    6. 'constructor
    7.     Public Sub New(ByVal data As Boundary)
    8.         MyBase.New()
    9.  
    10.         InitializeComponent()
    11.  
    12.         itsBoundary = data
    13.     End Sub
    14.  
    15.     Public Shadows Function ShowDialog(ByRef owner As IWin32Window) As Boundary
    16.         MyBase.ShowDialog(owner)       'call the base class version and ignore its return value
    17.         Return DialogResult       'return our own data
    18.     End Function
    19.  
    20.     Public Shadows Property DialogResult() As Boundary
    21.         Get
    22.             Return itsDialogResult
    23.         End Get
    24.         Set(ByVal Value As Boundary)
    25.             itsDialogResult = Value
    26.         End Set
    27.     End Property
    28.  
    29. 'other code omitted for clarity
    30.  
    31.     Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
    32.         DialogResult = Nothing
    33.         Me.Close()
    34.     End Sub
    35.  
    36.     Private Sub cmdOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOK.Click
    37.         DialogResult = itsBoundary
    38.         Me.Close()
    39.     End Sub
    40.  
    41. 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.

  2. #2
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769
    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
  •  



Click Here to Expand Forum to Full Width