Getting the contents of a standard old fashion text string into a dialog textbox.

A quick howto question.

I need to get the contents of a standard old fashion text string into a dialog textbox. Here is a code example from Form1.h...

...

public:

Form1(void)

{

char test[132];

InitializeComponent();

//

//TODO: Add the constructor code here

//

strcpy(test,someglobalstring);

FileInText->Text = test;//This gives a compiler error, How do I make it work
//FileInText is the textbox...

FileInText->Text = "This is a test";    //This works fine

}




Answer this question

Getting the contents of a standard old fashion text string into a dialog textbox.

  • pbergeron

    Maybe it's my complete lack of understanding of C++ (I'm just an old time C programmer), but this still gave me a compiler error...

    error C2664: 'void System::Windows::Forms::Control::Text::set(System::String ^)' : cannot convert parameter 1 from 'System::String' to 'System::String ^'

    No user-defined-conversion operator available, or

    No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

    If I add the... User System::String:

    I get a different error for it...

    error C2065: 'User' : undeclared identifier



  • Manfred Mejias

    I am sorry! But I am also just a beginner in the managed worls, so I knew that I can directly convert a char* to System::String but I forgot that I need a handle to the managed object.

    So this should work, even if I didn't try it. Big Smile
    FileInText->Text = gcnew System::String(test);

    If you look at the compiler message you can see it by your own. There was only no converstion from System::String to System::String ^


  • shreeman

    User System::String:

    char test[132];
    strcpy(test, something);

    FileInText->Text = System::String(test);



  • Getting the contents of a standard old fashion text string into a dialog textbox.