473,788 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VS2005 DialogResult

rk
According to the docs, I would expect to check the result of an
OpenFileDialog in a VS 2005 CLR Windows Forms application this way:

if (openFileDialog 1->ShowDialog() ==
DialogResult::O K)

However, this does not work, and I have to use:

if (openFileDialog 1->ShowDialog() ==
System::Windows ::Forms::Dialog Result::OK)

Did I miss anything, or is this a bug?

Thanks
Richard
Feb 28 '06 #1
11 2659
Hi rk!
According to the docs, I would expect to check the result of an
OpenFileDialog in a VS 2005 CLR Windows Forms application this way:

if (openFileDialog 1->ShowDialog() ==
DialogResult::O K)

However, this does not work, and I have to use:

if (openFileDialog 1->ShowDialog() ==
System::Windows ::Forms::Dialog Result::OK)

Did I miss anything, or is this a bug?


The short-version only works, if you have added

using System::Windows ::Forms;

at the top (or at least before you use the above code).
Or did I miss something in your post?

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Feb 28 '06 #2
"Jochen Kalmbach [MVP]" <no************ ********@holzma .de> wrote in message
news:u9******** ******@TK2MSFTN GP11.phx.gbl...
Hi rk!
According to the docs, I would expect to check the result of an
OpenFileDialog in a VS 2005 CLR Windows Forms application this way:

if (openFileDialog 1->ShowDialog() ==
DialogResult::O K)

However, this does not work, and I have to use:

if (openFileDialog 1->ShowDialog() ==
System::Windows ::Forms::Dialog Result::OK)

Did I miss anything, or is this a bug?


The short-version only works, if you have added

using System::Windows ::Forms;


using namespace System::Windows ::Forms;

that is...

-cd
Feb 28 '06 #3
rk
Hi Jochen,

I had added

using namespace System::Windows ::Forms;

but this did not prevent the problem. I know, that

if (openFileDialog 1->ShowDialog() ==
System::Windows ::Forms::Dialog Result::OK)

and

using namespace System::Windows ::Forms;
if (openFileDialog 1->ShowDialog()== DialogResult::O K)

should be equivalent. So I would expect it to be a bug if they are not.

Or not?

Richard
Jochen Kalmbach [MVP] schrieb:
Hi rk!
According to the docs, I would expect to check the result of an
OpenFileDialog in a VS 2005 CLR Windows Forms application this way:

if (openFileDialog 1->ShowDialog() ==
DialogResult::O K)

However, this does not work, and I have to use:

if (openFileDialog 1->ShowDialog() ==
System::Windows ::Forms::Dialog Result::OK)

Did I miss anything, or is this a bug?


The short-version only works, if you have added

using System::Windows ::Forms;

at the top (or at least before you use the above code).
Or did I miss something in your post?

Feb 28 '06 #4
Hi rk!
using namespace System::Windows ::Forms;

but this did not prevent the problem. I know, that

if (openFileDialog 1->ShowDialog() ==
System::Windows ::Forms::Dialog Result::OK)

and

using namespace System::Windows ::Forms;
if (openFileDialog 1->ShowDialog()== DialogResult::O K)

should be equivalent. So I would expect it to be a bug if they are not.


What prolems do you get???
For me it works without any problems in VS2003 and VS2005...

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Feb 28 '06 #5
Hi Jochen,

strange. When compiling

private: System::Void openToolStripMe nuItem_Click(Sy stem::Object^
sender, System::EventAr gs^ e) {

if (openFileDialog 1->ShowDialog() == DialogResult::O K)
//System::Windows ::Forms::Dialog Result::OK) // this works
{
richTextBox1->LoadFile(openF ileDialog1->FileName);
}
}
I get

1>c:\vs2005\pro jekt1\projekt1\ Form1.h(156) : error C2039: 'OK': Ist
kein Element von 'System::Window s::Forms::Form: :DialogResult'
1> c:\vs2005\proje kt1\projekt1\Fo rm1.h(23): Siehe Deklaration
von 'System::Window s::Forms::Form: :DialogResult'
1>c:\vs2005\pro jekt1\projekt1\ Form1.h(156) : error C2065: 'OK':
nichtdeklariert er Bezeichner
1>Das Buildprotokoll wurde unter
"file://c:\VS2005\Proje kt1\Projekt1\De bug\BuildLog.ht m" gespeichert.
1>Projekt1 - 2 Fehler, 0 Warnung(en)

If this works for you - what could I have done wrong?

I am using

Microsoft Visual Studio 2005
Version 8.0.50727.42 (RTM.050727-4200)
Microsoft .NET Framework
Version 2.0.50727
Installierte Edition: Professional

Thanks
Richard

Jochen Kalmbach [MVP] schrieb:
Hi rk!
using namespace System::Windows ::Forms;

but this did not prevent the problem. I know, that

if (openFileDialog 1->ShowDialog() ==
System::Windows ::Forms::Dialog Result::OK)

and

using namespace System::Windows ::Forms;
if (openFileDialog 1->ShowDialog()== DialogResult::O K)

should be equivalent. So I would expect it to be a bug if they are not.


What prolems do you get???
For me it works without any problems in VS2003 and VS2005...

Feb 28 '06 #6
Hallo R!

private: System::Void openToolStripMe nuItem_Click(Sy stem::Object^
sender, System::EventAr gs^ e) {

if (openFileDialog 1->ShowDialog() == DialogResult::O K)
{
richTextBox1->LoadFile(openF ileDialog1->FileName);
}
}
I get

1>c:\vs2005\pro jekt1\projekt1\ Form1.h(156) : error C2039: 'OK': Ist
kein Element von 'System::Window s::Forms::Form: :DialogResult'
1> c:\vs2005\proje kt1\projekt1\Fo rm1.h(23): Siehe Deklaration
von 'System::Window s::Forms::Form: :DialogResult'


Ok! Now I see the problem!
You are using this inside a Form-derived class...
The Form itself contains a member called "DialogResu lt".
The compiler is using this member instead of the enum...

Also if you enter "::" after "DialogResu lt" you get the "correct" hint
(you have only "get" or "set" and no values of the enum!).

AFAIK the shortest version is:
Windows::Forms: :DialogResult:: OK

Inside a Form...

By the way: Es gibt auch eine deutschsprachig e newsgroup für managed C++
/ C++/CLI:
microsoft.publi c.de.german.ent wickler.dotnet. vc

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Feb 28 '06 #7
Jochen Kalmbach [MVP] schrieb:
Hallo R!

private: System::Void openToolStripMe nuItem_Click(Sy stem::Object^
sender, System::EventAr gs^ e) {

if (openFileDialog 1->ShowDialog() == DialogResult::O K)
{
richTextBox1->LoadFile(openF ileDialog1->FileName);
}
}
I get

1>c:\vs2005\pro jekt1\projekt1\ Form1.h(156) : error C2039: 'OK': Ist
kein Element von 'System::Window s::Forms::Form: :DialogResult'
1> c:\vs2005\proje kt1\projekt1\Fo rm1.h(23): Siehe Deklaration
von 'System::Window s::Forms::Form: :DialogResult'
Ok! Now I see the problem!
You are using this inside a Form-derived class...
The Form itself contains a member called "DialogResu lt".


Thanks, that would be an explanation.

But where does this member come from? I have not inserted it.
The compiler is using this member instead of the enum...

Also if you enter "::" after "DialogResu lt" you get the "correct" hint
(you have only "get" or "set" and no values of the enum!).

AFAIK the shortest version is:
Windows::Forms: :DialogResult:: OK

Inside a Form...

By the way: Es gibt auch eine deutschsprachig e newsgroup für managed C++
/ C++/CLI:
microsoft.publi c.de.german.ent wickler.dotnet. vc
Vielen Dank

Richard Kaiser

Feb 28 '06 #8
Hallo R!
Ok! Now I see the problem!
You are using this inside a Form-derived class...
The Form itself contains a member called "DialogResu lt".


Thanks, that would be an explanation.

But where does this member come from? I have not inserted it.


It is a member of the "Form"-class:
http://msdn2.microsoft.com/en-us/lib...logresult.aspx

Also in the example they use
::DialogResult: :OK
as a shortcut... but it does not compile...

Maybe there is a shorted way; but I do not know it currently...

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Feb 28 '06 #9
Jochen Kalmbach [MVP] schrieb:
Hallo R!
Ok! Now I see the problem!
You are using this inside a Form-derived class...
The Form itself contains a member called "DialogResu lt".


Thanks, that would be an explanation.

But where does this member come from? I have not inserted it.


It is a member of the "Form"-class:
http://msdn2.microsoft.com/en-us/lib...logresult.aspx
Also in the example they use
::DialogResult: :OK
as a shortcut... but it does not compile...

Maybe there is a shorted way; but I do not know it currently...


Vielen Dank
Richard Kaiser
Feb 28 '06 #10

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

Similar topics

5
3700
by: Daniel | last post by:
what do you have to do in a C# dialog so that it returns to ShowDialog as DialogResult.OK ?
2
17747
by: steve bull | last post by:
I have built what I think should be a dialog box. It contains 4 tabbed panes for generating a range of colors. Each tabbed pane consists of a panel with all the widgets on them including the OK and Cancel buttons. These buttons have to be on the panels themselves so that they can create the color range from the current settings on the panel and return the result via a delegate to the main dialog form. The problem I have is that the OK...
7
2648
by: Frank Maxey | last post by:
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
2
7549
by: dm1608 | last post by:
I'm opening my own form and doing something like: If dlgDirectory.ShowDialog() = DialogResult.OK Then .... End If When I compile the project, I can a warning for the line saying: Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated.
8
1203
by: BK | last post by:
Converting a rather large solution from 2003 to 2005. All the errors are worked out, but I'm trying to clean up the warnings as best I can. The good news is that the application and it's supporting assemblies are all working now. The followins snippet is from a base form class I use in the application. Pretty typical stuff, when a data entry form is closing and if the user is editing data, I want to allow them to save their work. ...
1
2362
by: Bill Cart | last post by:
I am trying to work with 2 forms. If I set the ModalResult of a button on the 2nd form it works OK. If I try to assign the result and then return it does not return the value I set. 1st Form (calling form) DeliveryInfo DeliveryFrm = new DeliveryInfo(Convert.ToInt32(this.uniqueIDTextBox.Text)); DialogResult result;
7
5590
by: Masterfrier | last post by:
Hi there! in my app, i open a Dialog, in this dialog i use the FileOpenDialog, when i click on 'Ok' or 'Cancel' in my FileOpenDialog, it automatically closes the parent dialog, with a DialogResult.Cancel??? I have overloaded the ShowDialog to accept parameters in the 'Parent' Dialog main Code ...Calling Parent Dialog
2
6997
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, these buttons are not labelled "OK" and "No"). Settting this property is very convenient, I don't need to write any code determining what should happen when one of these buttons is clicked. Anyway, now I need to add a third button and I guess I...
0
9656
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10366
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10173
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9967
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3674
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.