473,395 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Problem with DialogResult property

I am fairly new to VB.Net and am having a curious problem.

I have an entry dialog form called from a main form. The calling form
needs to check the
DialogResult field for an OK response.

In my button service in the dialog form, I have:

Private Sub btnSave_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnSave.Click
Nov 20 '05 #1
7 2621
Frank:

Have you set the AcceptButton and CancelButton and/or are you setting the
dialogresult within the form?
"Frank Maxey" <fd*****@yahoo.com> wrote in message
news:12**************************@posting.google.c om...
I am fairly new to VB.Net and am having a curious problem.

I have an entry dialog form called from a main form. The calling form
needs to check the
DialogResult field for an OK response.

In my button service in the dialog form, I have:

Private Sub btnSave_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnSave.Click
.
.
.
Me.DialogResult = DialogResult.OK
Me.Hide()
End Sub
The call to the form is:

Dim frm As EntryForm

frm = New EntryForm()

Dim res as DialogResult = frm.ShowDialog()

If res = DialogResult.OK Then
< Service OK response>
End If

frm = Nothing
The Save button click service is definitely called but the result in
the
calling form always shows DialogResult.Cancel. If I step through the
code, the DialogResult is set to OK up to and including the Hide
method
call. However, the result is always Cancel.

I've tried changing the code to:

frm.ShowDialog()
Dim res as DialogResult = frm.DialogResult

with no success

I'm missing something obvious here, but I don't know what.

TIA

Frank Maxey
fd*************@yahoo.com
(Remove 'KeinSpam' to reply to my e-mail address)

Nov 20 '05 #2
Frank, I just saw you did, my oversight.
"Frank Maxey" <fd*****@yahoo.com> wrote in message
news:12**************************@posting.google.c om...
I am fairly new to VB.Net and am having a curious problem.

I have an entry dialog form called from a main form. The calling form
needs to check the
DialogResult field for an OK response.

In my button service in the dialog form, I have:

Private Sub btnSave_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnSave.Click
.
.
.
Me.DialogResult = DialogResult.OK
Me.Hide()
End Sub
The call to the form is:

Dim frm As EntryForm

frm = New EntryForm()

Dim res as DialogResult = frm.ShowDialog()

If res = DialogResult.OK Then
< Service OK response>
End If

frm = Nothing
The Save button click service is definitely called but the result in
the
calling form always shows DialogResult.Cancel. If I step through the
code, the DialogResult is set to OK up to and including the Hide
method
call. However, the result is always Cancel.

I've tried changing the code to:

frm.ShowDialog()
Dim res as DialogResult = frm.DialogResult

with no success

I'm missing something obvious here, but I don't know what.

TIA

Frank Maxey
fd*************@yahoo.com
(Remove 'KeinSpam' to reply to my e-mail address)

Nov 20 '05 #3
I have had this problem before and the only thing I can tell you (since I
never figured it out) is make your own form property. That works.

"Frank Maxey" <fd*****@yahoo.com> wrote in message
news:12**************************@posting.google.c om...
I am fairly new to VB.Net and am having a curious problem.

I have an entry dialog form called from a main form. The calling form
needs to check the
DialogResult field for an OK response.

In my button service in the dialog form, I have:

Private Sub btnSave_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnSave.Click
.
.
.
Me.DialogResult = DialogResult.OK
Me.Hide()
End Sub
The call to the form is:

Dim frm As EntryForm

frm = New EntryForm()

Dim res as DialogResult = frm.ShowDialog()

If res = DialogResult.OK Then
< Service OK response>
End If

frm = Nothing
The Save button click service is definitely called but the result in
the
calling form always shows DialogResult.Cancel. If I step through the
code, the DialogResult is set to OK up to and including the Hide
method
call. However, the result is always Cancel.

I've tried changing the code to:

frm.ShowDialog()
Dim res as DialogResult = frm.DialogResult

with no success

I'm missing something obvious here, but I don't know what.

TIA

Frank Maxey
fd*************@yahoo.com
(Remove 'KeinSpam' to reply to my e-mail address)

Nov 20 '05 #4
I figured to add a property as a last resort, but I would have liked
to use the standard properties. I set the Cancel and Accept buttons,
just to be sure, but it didn't do any good.

It was at least reassuring to know somebody else had the same problem.
Thanks

Frank Maxey
fd*************@yahoo.com
(Remove 'KeinSpam' to reply to my e-mail address)

"Juan Romero" <ju*********@bowne.com> wrote in message news:<eu**************@TK2MSFTNGP09.phx.gbl>...
I have had this problem before and the only thing I can tell you (since I
never figured it out) is make your own form property. That works.

"Frank Maxey" <fd*****@yahoo.com> wrote in message
news:12**************************@posting.google.c om...
I am fairly new to VB.Net and am having a curious problem.

I have an entry dialog form called from a main form. The calling form
needs to check the
DialogResult field for an OK response.

In my button service in the dialog form, I have:

Private Sub btnSave_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnSave.Click
.
.
.
Me.DialogResult = DialogResult.OK
Me.Hide()
End Sub
The call to the form is:

Dim frm As EntryForm

frm = New EntryForm()

Dim res as DialogResult = frm.ShowDialog()

If res = DialogResult.OK Then
< Service OK response>
End If

frm = Nothing
The Save button click service is definitely called but the result in
the
calling form always shows DialogResult.Cancel. If I step through the
code, the DialogResult is set to OK up to and including the Hide
method
call. However, the result is always Cancel.

I've tried changing the code to:

frm.ShowDialog()
Dim res as DialogResult = frm.DialogResult

with no success

I'm missing something obvious here, but I don't know what.

TIA

Frank Maxey
fd*************@yahoo.com
(Remove 'KeinSpam' to reply to my e-mail address)

Nov 20 '05 #5
Frank,
Normally what I do is what William Ryan was asking about.

On the DialogForm form:
Form.AcceptButton = buttonSave
Form.CancelButton = buttonCancel

On the buttonSave button:
Button.DialogResult = DialogResult.Ok

On the buttonCancel button:
Button.DialogResult = DialogResult.Cancel
The Form will automatically handle setting Form.DialogResult & calling
Form.Hide when you click either button, or press the Enter or Cancel key.

Alternatively, if you set Form.DialogResult within your event handler, Hide
is automatically called for you.

Is this with VS.NET 2002 or VS.NET 2003? I could not replicate you problem
with VS.NET 2003.

Hope this helps
Jay

"Frank Maxey" <fd*****@yahoo.com> wrote in message
news:12*************************@posting.google.co m...
I figured to add a property as a last resort, but I would have liked
to use the standard properties. I set the Cancel and Accept buttons,
just to be sure, but it didn't do any good.

It was at least reassuring to know somebody else had the same problem.
Thanks

Frank Maxey
fd*************@yahoo.com
(Remove 'KeinSpam' to reply to my e-mail address)

"Juan Romero" <ju*********@bowne.com> wrote in message

news:<eu**************@TK2MSFTNGP09.phx.gbl>...
I have had this problem before and the only thing I can tell you (since I never figured it out) is make your own form property. That works.

"Frank Maxey" <fd*****@yahoo.com> wrote in message
news:12**************************@posting.google.c om...
I am fairly new to VB.Net and am having a curious problem.

I have an entry dialog form called from a main form. The calling form
needs to check the
DialogResult field for an OK response.

In my button service in the dialog form, I have:

Private Sub btnSave_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnSave.Click
.
.
.
Me.DialogResult = DialogResult.OK
Me.Hide()
End Sub
The call to the form is:

Dim frm As EntryForm

frm = New EntryForm()

Dim res as DialogResult = frm.ShowDialog()

If res = DialogResult.OK Then
< Service OK response>
End If

frm = Nothing
The Save button click service is definitely called but the result in
the
calling form always shows DialogResult.Cancel. If I step through the
code, the DialogResult is set to OK up to and including the Hide
method
call. However, the result is always Cancel.

I've tried changing the code to:

frm.ShowDialog()
Dim res as DialogResult = frm.DialogResult

with no success

I'm missing something obvious here, but I don't know what.

TIA

Frank Maxey
fd*************@yahoo.com
(Remove 'KeinSpam' to reply to my e-mail address)

Nov 20 '05 #6
I have the 2002 version.

I had already tried setting the buttons that you outline below, with
no success. I found it was easier and more straightforward to create
another property for the form.

According to the Microsoft's documentation (I should know better by
now) it should be sufficient just to use:

Form.DialogResult = DialogResult.OK
Form.Hide()

I think I'll just stick with writing my own properties explicitly. At
least I can be certain how they work.

Thanks for the reply.

Frank Maxey
fd*************@yahoo.com
(Remove 'KeinSpam' to reply to my e-mail address)

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:<#0**************@TK2MSFTNGP10.phx.gbl>...
Frank,
Normally what I do is what William Ryan was asking about.

On the DialogForm form:
Form.AcceptButton = buttonSave
Form.CancelButton = buttonCancel

On the buttonSave button:
Button.DialogResult = DialogResult.Ok

On the buttonCancel button:
Button.DialogResult = DialogResult.Cancel
The Form will automatically handle setting Form.DialogResult & calling
Form.Hide when you click either button, or press the Enter or Cancel key.

Alternatively, if you set Form.DialogResult within your event handler, Hide
is automatically called for you.

Is this with VS.NET 2002 or VS.NET 2003? I could not replicate you problem
with VS.NET 2003.

Hope this helps
Jay

"Frank Maxey" <fd*****@yahoo.com> wrote in message
news:12*************************@posting.google.co m...
I figured to add a property as a last resort, but I would have liked
to use the standard properties. I set the Cancel and Accept buttons,
just to be sure, but it didn't do any good.

It was at least reassuring to know somebody else had the same problem.
Thanks

Frank Maxey
fd*************@yahoo.com
(Remove 'KeinSpam' to reply to my e-mail address)

"Juan Romero" <ju*********@bowne.com> wrote in message

news:<eu**************@TK2MSFTNGP09.phx.gbl>...
I have had this problem before and the only thing I can tell you (since I never figured it out) is make your own form property. That works.

"Frank Maxey" <fd*****@yahoo.com> wrote in message
news:12**************************@posting.google.c om...
> I am fairly new to VB.Net and am having a curious problem.
>
> I have an entry dialog form called from a main form. The calling form
> needs to check the
> DialogResult field for an OK response.
>
> In my button service in the dialog form, I have:
>
> Private Sub btnSave_Click(ByVal sender As System.Object, _
> ByVal e As System.EventArgs) Handles btnSave.Click
>
>
> .
> .
> .
> Me.DialogResult = DialogResult.OK
> Me.Hide()
> End Sub
>
>
> The call to the form is:
>
> Dim frm As EntryForm
>
> frm = New EntryForm()
>
> Dim res as DialogResult = frm.ShowDialog()
>
> If res = DialogResult.OK Then
> < Service OK response>
> End If
>
> frm = Nothing
>
>
> The Save button click service is definitely called but the result in
> the
> calling form always shows DialogResult.Cancel. If I step through the
> code, the DialogResult is set to OK up to and including the Hide
> method
> call. However, the result is always Cancel.
>
> I've tried changing the code to:
>
> frm.ShowDialog()
> Dim res as DialogResult = frm.DialogResult
>
> with no success
>
> I'm missing something obvious here, but I don't know what.
>
> TIA
>
> Frank Maxey
> fd*************@yahoo.com
> (Remove 'KeinSpam' to reply to my e-mail address)

Nov 20 '05 #7
Frank,
According to the Microsoft's documentation (I should know better by
now) it should be sufficient just to use:

Form.DialogResult = DialogResult.OK
Form.Hide()
What documentation??? Remember documentation can be wrong or misleading...
You actually do not need the Form.Hide!

All you need in VS.NET 2002 & VS.NET 2003 is:

Private Sub btnSave_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnSave.Click
Me.DialogResult = DialogResult.OK
End Sub

However I prefer setting the Button.DialogResult & Form.AcceptButton, then I
do not need the event handlers. Which also works in both VS.NET 2002 &
VS.NET 2003.

Can you post (if its small) or email me a complete sample of what you are
doing, I am not able to recreate what you describe, given the information
you posted.

IMPORTANT: Within in your EntryForm are you setting DialogResult any place
other then the button's click event handlers? Such as the Closed event?

The only way I was able to recreate what you are seeing is by adding the
following to my form:

Private Sub AboutDialog_Closed(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Closed
Me.DialogResult = DialogResult.Cancel
End Sub

Which definitely is not needed, as the form automatically returns Cancel if
you click the Close button!

Hope this helps
Jay

"Frank Maxey" <fd*****@yahoo.com> wrote in message
news:12**************************@posting.google.c om... I have the 2002 version.

I had already tried setting the buttons that you outline below, with
no success. I found it was easier and more straightforward to create
another property for the form.

According to the Microsoft's documentation (I should know better by
now) it should be sufficient just to use:

Form.DialogResult = DialogResult.OK
Form.Hide()

I think I'll just stick with writing my own properties explicitly. At
least I can be certain how they work.

Thanks for the reply.

Frank Maxey
fd*************@yahoo.com
(Remove 'KeinSpam' to reply to my e-mail address)

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message

news:<#0**************@TK2MSFTNGP10.phx.gbl>...
Frank,
Normally what I do is what William Ryan was asking about.

On the DialogForm form:
Form.AcceptButton = buttonSave
Form.CancelButton = buttonCancel

On the buttonSave button:
Button.DialogResult = DialogResult.Ok

On the buttonCancel button:
Button.DialogResult = DialogResult.Cancel
The Form will automatically handle setting Form.DialogResult & calling
Form.Hide when you click either button, or press the Enter or Cancel key.
Alternatively, if you set Form.DialogResult within your event handler, Hide is automatically called for you.

Is this with VS.NET 2002 or VS.NET 2003? I could not replicate you problem with VS.NET 2003.

Hope this helps
Jay

"Frank Maxey" <fd*****@yahoo.com> wrote in message
news:12*************************@posting.google.co m...
I figured to add a property as a last resort, but I would have liked
to use the standard properties. I set the Cancel and Accept buttons,
just to be sure, but it didn't do any good.

It was at least reassuring to know somebody else had the same problem.
Thanks

Frank Maxey
fd*************@yahoo.com
(Remove 'KeinSpam' to reply to my e-mail address)

"Juan Romero" <ju*********@bowne.com> wrote in message

news:<eu**************@TK2MSFTNGP09.phx.gbl>...
> I have had this problem before and the only thing I can tell you (since
I
> never figured it out) is make your own form property. That works.
>
> "Frank Maxey" <fd*****@yahoo.com> wrote in message
> news:12**************************@posting.google.c om...
> > I am fairly new to VB.Net and am having a curious problem.
> >
> > I have an entry dialog form called from a main form. The calling

form > > needs to check the
> > DialogResult field for an OK response.
> >
> > In my button service in the dialog form, I have:
> >
> > Private Sub btnSave_Click(ByVal sender As System.Object, _
> > ByVal e As System.EventArgs) Handles btnSave.Click > >
> >
> > .
> > .
> > .
> > Me.DialogResult = DialogResult.OK
> > Me.Hide()
> > End Sub
> >
> >
> > The call to the form is:
> >
> > Dim frm As EntryForm
> >
> > frm = New EntryForm()
> >
> > Dim res as DialogResult = frm.ShowDialog()
> >
> > If res = DialogResult.OK Then
> > < Service OK response>
> > End If
> >
> > frm = Nothing
> >
> >
> > The Save button click service is definitely called but the result in > > the
> > calling form always shows DialogResult.Cancel. If I step through the > > code, the DialogResult is set to OK up to and including the Hide
> > method
> > call. However, the result is always Cancel.
> >
> > I've tried changing the code to:
> >
> > frm.ShowDialog()
> > Dim res as DialogResult = frm.DialogResult
> >
> > with no success
> >
> > I'm missing something obvious here, but I don't know what.
> >
> > TIA
> >
> > Frank Maxey
> > fd*************@yahoo.com
> > (Remove 'KeinSpam' to reply to my e-mail address)

Nov 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Hautzendorfer | last post by:
Hello, I'm currently working on some printing stuff: I have to print out several .xml files using a stylesheet. Therefor I choose the Internetexplorer PlugIn via SHDocVW. My problem: After...
11
by: Robert Schuldenfrei | last post by:
I am an older person trying to learn C# just for the fun of it. I am a veteran of older style languages (COBOL, FORTRAN, etc.) and I want to learn an Object Orientated language. Currently working...
1
by: Beeeeeeeeeeeeves | last post by:
Something tells me that there is a single-method way of accomplishing this. When you click the button that is designated as the cancel button, the form automatically acts as if it has been dismissed,...
5
by: Daniel | last post by:
what do you have to do in a C# dialog so that it returns to ShowDialog as DialogResult.OK ?
1
by: Marcin Zmyslowski | last post by:
Hello everybody! I have the problem with using Button1.PerformClick() method. I don`t know how to call the button. I have been searching the newsgroups but I didn`t find any exact description...
7
by: Sergey Poberezovskiy | last post by:
Hi, I created two base forms: frmList and frmDetail, compiled them into a dll, and then want to use in my new project. The problem: When I created new inherited form, say frmClients, I cannot...
4
by: Rod Gill | last post by:
Hi, I have a form that when opened in the designer appears of the screen. The form selector can't be dragged (or resized) and if I scroll right and down to centralise it the form simply jumps...
18
by: **Developer** | last post by:
If e.Button = MouseButtons.Left Then also from a Dim Answer As DialogResult = MessageBox.Show.. Select Case Answer Case DialogResult.Yes
2
by: WP | last post by:
Hello, I making and Windows Forms program and I have a dialog with two buttons. I have set the DialogResult property for these buttons to DialogResult.OK and DialogResult.No, respectively (however,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.