none
How to load a vector into a richtext box window RRS feed

  • Question

  • I have a richtext box I need vector data displayed in.

    I am already converting it to System::String but cannot find the combination to inserting it without crashing my application.

    string element0;
    element0 = laVector.at(0);
    String^ newElement0 = gcnew String(element0.c_str());
    richTextBox1->LoadFile(newElement0, RichTextBoxStreamType::PlainText );

    Loadfile() I am sure is incorrect and newElement0 is what is crashing my application.

    Wednesday, September 26, 2012 4:44 PM

Answers

All replies

  • I get the following error with the above and with this

    string element0;
    element0 = laVector.at(0);
    String^ newElement0 = gcnew String(element0.c_str());
    this->Text=newElement0;
    richTextBox1->LoadFile(newElement0, RichTextBoxStreamType::PlainText );

    See the end of this message for details on invoking 
    just-in-time (JIT) debugging instead of this dialog box.

    ************** Exception Text **************
    System.ArgumentException: Illegal characters in path.
       at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)
       at System.IO.Path.GetFileName(String path)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
       at System.Windows.Forms.RichTextBox.LoadFile(String path, RichTextBoxStreamType fileType)
       at winForm1.Form1.LoadMyFile() in c:\users\wuzamarine\documents\visual studio 2010\projects\winform1\winform1\form1.h:line 410
       at winForm1.Form1.button1_Click(Object sender, EventArgs e) in c:\users\wuzamarine\documents\visual studio 2010\projects\winform1\winform1\form1.h:line 393
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


    ************** Loaded Assemblies **************
    mscorlib
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
        CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
    ----------------------------------------
    winForm1
        Assembly Version: 1.0.4652.22727
        Win32 Version: 
        CodeBase: file:///C:/Users/wuzamarine/Documents/Visual%20Studio%202010/Projects/winForm1/Debug/winForm1.exe
    ----------------------------------------
    System.Windows.Forms
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll

    Wednesday, September 26, 2012 5:42 PM
  • Vector data inside newElement0 as per Visual Studio debugging :

    newElement0 = " terminator.mp4  Duration: 00:"

    Which is correct.

    Wednesday, September 26, 2012 5:44 PM
  • Vector data inside newElement0 as per Visual Studio debugging :

    newElement0 = " terminator.mp4  Duration: 00:"

    Which is correct.

    Hi Wuzamarine,

    Please note, the Loadfile method: http://msdn.microsoft.com/en-us/library/d76176b1.aspx  

    The first parameter is a file path, not the the file content string.

    Because you have got the file content string, I suggest you try this property: http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.text.aspx 

    I hope this will be helpful.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, September 27, 2012 11:08 AM
    Moderator