none
Converting System::Uri^ to System::String^

    Question

  • I'd like to display the webBrowser URL inside a textbox.

    This is what I have- this->toolStripComboBox1->Text = this->webBrowser1->Url;

    Although this error occurs..

    1>c:\users\jeanie\documents\visual studio 2010\projects\mybrowser\mybrowser\Form1.h(362): error C2664: 'void System::Windows::Forms::ToolStripItem::Text::set(System::String ^)' : cannot convert parameter 1 from 'System::Uri ^' to 'System::String ^'
    1>          No user-defined-conversion operator available, or
    1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

    I understand what it means, but how can I convert it to string? Thanks!

    Saturday, December 11, 2010 8:52 PM

Answers

  • call the ToString method of the Uri class.

    If you need more help using classes in the .Net base class library, try the .Net Base Class library forum under the .net development category.



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    • Marked as answer by JTallis Saturday, December 11, 2010 11:17 PM
    Saturday, December 11, 2010 10:06 PM

All replies

  • call the ToString method of the Uri class.

    If you need more help using classes in the .Net base class library, try the .Net Base Class library forum under the .net development category.



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    • Marked as answer by JTallis Saturday, December 11, 2010 11:17 PM
    Saturday, December 11, 2010 10:06 PM
  • Yeah. I just saw this method used else where...

    			String^ url1;
    			url1 = System::Convert::ToString(this->webBrowser1->Url);
    			this->toolStripComboBox1->Text = url1;
    
    Works great for me.

     

    Saturday, December 11, 2010 11:16 PM