Just thinking about "translating" C# into (Visual) C++ code is a "piece of cake".
However, DataGridView Class is .NET stuff, then you cannot simply derive from it "like a walking in the park", let's say, in an MFC application.
Basically, I see two choices:
get rid of .NET's DataGridView and replace it with an unmanaged component, e.g. "Microsoft Data Grid" ActiveX control, or
make a separate .NET Class Libray project to implement the grid, then "import" it in the MFC application; not sure about this one, but may try this article as a "start digging point".
Last edited by ovidiucucu; April 9th, 2012 at 04:54 AM.
I Checked...Its giving the following errors. Further is it possible to learn.....?
Please note that your code and questions are off-topic for this forum. The code you're attempting to compile is not "traditional" C++, with emphasis on MFC and ATL (that is what this forum is about).
You should post any follow-ups in the Managed C++ forum.
Errors:
01. warning C4490: 'override' : incorrect use of override specifier; 'MyDGV::ProcessDialogKey' does not match a base ref class method
02.error C3063: operator '&': all operands must have the same enumeration type
03.error C2275: 'System::Windows::Forms::Keys' : illegal use of this type as an expression
04.error C2275: 'System::Windows::Forms::Keys' : illegal use of this type as an expression
Keys is a managed enum, not a reference type. (As such it's much closer to a value type than a reference type, yet managed enums and value types are different animals.) Removing all the ^s, which are mostly used with reference types in C++/CLI, from David Anton's snippet should get you some steps further.
Though they're caused by the bogus ^s as well, some specific notes on the first two errors/warnings:
C4490: The DGV does have a virtual method of that name, but that takes a parameter of type Keys, not Keys ^. These two different signatures are considered two distinct overloads.
C3063: This is due to the fact that the left-hand side of the & is of type Keys ^ while the right-hand side Keys::KeyCode is of the correct type Keys.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
The last line of that snippet works but is terribly inefficient. The commented-out line would work as well (after adding a { at the end of course, to get the syntax right).
However, key is still declared with an extraneous ^. That way it's a tracking handle to a boxed Keys instance instead of simply being a Keys instance itself. This is a rarely needed construct that would work here as well but also is unnecessarily inefficient. Simply removig the ^ makes it what it should be.
So this is how I would probably write that snippet:
Also, though rarely done, it is good practice and an aid to other readers to mark a thread [RESOLVED] using the Thread Tools menu at the top of the thread display once your question has been answered.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Re: [RESOLVED] Convert from C# to VC++2010 -dataGridView?
I agree about the "Keys" enum - the problem was that without a "using System.Windows.Forms", the converter can't confirm that "Keys" refers to the enum and not some other class of that name.
David Anton
Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com
Instant C# - VB to C# Converter
Instant VB - C# to VB Converter
Re: [RESOLVED] Convert from C# to VC++2010 -dataGridView?
Mostly out of curiosity...
Originally Posted by David Anton
[...] the problem was that without a "using System.Windows.Forms", the converter can't confirm that "Keys" refers to the enum and not some other class of that name.
What converter? Is there actually a converter from C# to C++/CLI? (And if there is, is it from MS? I'd rather expect them to publish a converter for the opposite direction. )
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Bookmarks