|
Damn it. I just discussed this last week and I can't find the answer in my notes. I want to set the current cell. The documentation has an example in C# is...
myDataGridView->CurrentCell = myDataGridView(1, 1);
I can't do this in C++/CLI. What is the correct syntax to set the current cell?
Buck
|
|
|
|
|
Don't bother, I've got it. Amazing how I can spend an hour trying to do something and then figure it out 5 minutes after posting. It's...
myDataGridView->CurrentCell = myDataGridView->Rows[row]->Cells[col];
|
|
|
|
|
Hi Buck, did you solve your mail problems and get my message?
Regards
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Evidently not. I'll go bug my IT guy again.
|
|
|
|
|
Buck,
BuckBrown wrote: myDataGridView->CurrentCell = myDataGridView->Rows[row]->Cells[col];
You can also do this:
myDataGridView->CurrentCell = dataGridView1[col, row];
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Thanks George,
I knew I had seen that syntax a couple of weeks ago. I kept trying to use parenthesis instead of brackets.
|
|
|
|
|
Thanks all for your input on my DataGridView question.
I am using visual 2005 C++/CLI. This seems like it should be pretty straight forward but I'm not doing so well at googling info on it. I have a Form1 that has a button on it that, when clicked, instantiates a Form2. After working on Form2 I would like to click a button on Form2 to update a file. The "UpdateFile()" function is a method of the Form1 class. I thought something like this->Parent->updatefile() or this->Owner->UpdateFile() might work but it doesn't. I am not real familiar with the Windows Owner/Parent/Child relashionships. How do I "look back" to the class that instantiated me and access one of that classes functions? Or can I?
Thanks
Buck
|
|
|
|
|
I'll reply to my own question. I believe I should use a delegate to do this.
|
|
|
|
|
That is dead right my friend!!
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
Hi Rocky,
I,m having some problems with this because all of the examples and documentation I have found show a delegate and a single class used from main(). I'm having a problem with a circular definition.
//-----This is in Class1.h------
#include "Class2.h"
delegate void MyDelegate();
public ref class Class1 : public System::Windows::Forms::Form
{
private: void UpdateFile()
{
// Body of Method
}
private: System::Void buttonAdvanced_Click(System::Object^ sender, System::EventArgs^ e)
{
Class2^ myclass2 = gcnew Class2();
myclass2->ShowDialog();
}
};
//-----This is in Class2.h------
#include "Class1.h" // I CAN"T DO THIS. THIS CLASS IS ALREADY INCLUDED IN Class1.h
public ref class Class2 : public System::Windows::Forms::Form
{
private: System::Void buttonUpdateFile_Click(System::Object^ sender, System::EventArgs^ e)
{
Class1^ myclass1 = gcnew Class1();
MyDelegate^ update_file = gcnew MyDelegate(myclass1, &Class1::UpdateFile);
}
};
The problem here is that I can't define MyDelegate^ update_file unless I #include Class1.h but class1.h already is #including Class2.h so the Class2 Form can be displayed, thus creating a circular dependancy. I haven't found any documentation on how to do what I am trying to do.
Thanks
Buck
|
|
|
|
|
Hi everyone,
We are developing a C++/CLI interfacing layer for our managed c# clients to talk to a legacy c++ app... we need to convert the DOTNET basic types like double, float, byte, short, string int values to void*
How should i do it
|
|
|
|
|
dreamz6480 wrote: convert
dreamz6480 wrote: to void*
Do you know what that means? .NET memory is managed you don't want the pointer to a .NET variable do you?
Based on your post I have no idea what your requirements are, one guess would be that you want to marshal the .NET memory to native memory[^], once you have the values in native memory I assume you know how to get the pointer to it.
|
|
|
|
|
If I were to need an interface between managed C# code and unmanaged C++ code, I would
do it in a C# class, I see no reason to put a third language in the middle.
And it would boil down to some P/Invoke stuff; for most value types there is a simple
1-to-1 correspondence (be careful with bool and long).
For reference types, things get more complicated. strings are simple, so are structs of
value types. Arrays and nested struct/classes may get tough.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hello Everyone,
well I got a bit peculiar problem here for u!
I've been given a program that is about making a Windows Service and it was developed in Visual C++ 6 and later converted to C++ .NET 1.1. Its using the CService Class. The thing they want me to find out is to how we can change the 'Startup Type' of that Windows Service after it has been installed.
Is this possible? if not then is it necessary for us to specify the startup type when installing the windows service.
Hope to hear from u ppl on this, any comments, suggestions are welcomed
Thanks in advance!
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
Rocky# wrote: we can change the 'Startup Type' of that Windows Service
They hide that information in the documentation[^]
|
|
|
|
|
Thanks alot Mike that was really helpful.
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
I don't know what "CService" is, and I also can't tell if you have a managed C++
question or not.
If you're code isn't managed C++, then you've posted on the wrong board, and
led mike has provided a solution.
If your service is a managed (.NET) service, then here's a quote from the docs:
"To change the StartType, you either have to uninstall and reinstall your service,
or manually change the setting using the Service Control Manager."
Of course, the unmanaged solution in led mike's link will work for any service -
the point is there's no .NET way to do it.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yea well Mike Solution was pretty helpful, the application wasnt managed coz it was built in VC++ 6.0 initially.
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
Rocky# wrote: developed in Visual C++ 6 and later converted to C++ .NET 1.1
When you state something like that, it's possible that the code was
converted to managed.
You may want to state the Visual Studio version you're using instead of
".NET 1.1" if you're not actually referring to the .NET framework.
For example, your post below is on the wrong board and has nothing to do with .NET.
I'm just trying to help you get better answers faster
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I'm working on a project and I need to use MSXML 4.0. I've added its Dll and .h file in stdafx.h but the problem is that the compiler is giving an ambiguity on this line
#import "msxml4.dll"
#include "msxml2.h"
using namespace MSXML2;
When i rt click on MSXML2 and click Go to Definition it gives me ambiguity in
C:\Program file\MSXML4.0\inc\msxml2.h
C:\Program file\...<visual studio's="" sdk="">\include\msxml2.h
and two other files named msxml2.tlh in Local Settings\temp folder
What should i do to get rid of this ambiguity?
Thanks in advance
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
Erm I may not fully understand the question but have you tried fully qualifying the include file path eg:
#include "C:\Program file\MSXML4.0\inc\msxml2.h"
as it sounds like you have more than one msxml.h in your projects default include and lib paths.
Hope this helps
Dan
|
|
|
|
|
Thanks for ur response Dan,
Actually I was giving the full quialified name for the file but the problem was somewhere else. and It got sorted out when i used the
'MSXML2::'
before the ambiguious names. It was addressed on the Microsoft website, surrently I dont have the URL with me. but I have sorted it out thankfully
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
Ahhhh there was an ambiguity between some function/object, so you may have had msxml2::DoSomething() and std::DoSomething and it didnt know which to choose so fully qualifying the function/object sorts it.
Any ways glad you sorted it.
Dan
|
|
|
|
|
Hello,
I wrote a managed C++ wrapper to integrate an unmanaged DLL into my C# application. From within this wrapper I have to pass a list of structures to C#:
struct structTwo{
int signal_value;
char text_info[PARSER_MAXSTRLEN];
};
struct structOne
{
int num_of_logical_values;
structTwo* logical_value; //<-- This is the list of the above structure
int num_of_physical_ranges;
int num_of_bcd_ranges;
int num_of_ascii_ranges;
};
So with one call to C# I would like to pass the whole structOne including the list of structTwos. Ok?
Passing a list of strings or INTs works fine using an ArrayList as parameter type:
ArrayList* stringList= new ArrayList();
for (int i=0; i<sporadic_frame_entries->num_of_frame_entries; i++)
{
stringList->Add(new String(theString));
}
Can I do this with the structure too? I tried several things but somehow I can't figure out.
Can someone suggest an appropriate solution?
thx
Steffen
|
|
|
|
|
IMHO there is no point in making C# code deal with a native structure when the memory must be marshaled anyway. Design a manged OO API and let the C++/CLI code deal with marshaling the memory from the native structures to the managed classes.
|
|
|
|