CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2016
    Location
    Los Angeles
    Posts
    6

    Re: Strings in VC Form buttons

    Experienced Boreland C programmer moving to VC - it's about time!

    So I dragged over a data structure from a DOS application, included it in the *c++ file and the it compiles.

    Now I want to use that structure to place the text in from buttons.

    where:
    Code:
    this->button2->Text = L"button2";
    I am modifying as follows:
    Code:
    this->button2->Text = src_lev[1].src_name1;
    and I get an error!

    structure file snippit. This is a proven good Boreland C file.

    Code:
    #define XPF 9999
    
    struct src_list {
    
    char *src_name1;
    char *src_name2;
    int src_num[11];
    
    } src_lev[] ={
    
    /* src top row bot row PAN HDa HDb SD REF LTC CNTL A12 A34 A56 A78 */
    /* 0 */ "", "", XPF, XPF, XPF, XPF, XPF, XPF, XPF, XPF, XPF, XPF, XPF,
    /* 1 */ "ResMac-1", "", 1, 5102, 5103, XPF, 193, XPF, XPF, 5104, 5106, 5108, 5110,
    /* 2 */ "ResMac-2", "", 2, 5115, 5116, XPF, 194, XPF, XPF, 5117, 5119, 5121, 5123,
    rest of structure not shown
    Last edited by adelle; May 4th, 2016 at 04:00 PM.

  2. #2
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: Strings in VC Form buttons

    Quote Originally Posted by adelle View Post
    Experienced Boreland C programmer moving to VC - it's about time!

    So I dragged over a data structure from a DOS application, included it in the *c++ file and the it compiles.

    Now I want to use that structure to place the text in from buttons.

    where:
    Code:
    this->button2->Text = L"button2";
    I am modifying as follows:
    Code:
    this->button2->Text = src_lev[1].src_name1;
    and I get an error!
    What error do you get?
    Victor Nijegorodov

  3. #3
    Join Date
    May 2016
    Location
    Los Angeles
    Posts
    6

    Re: Strings in VC Form buttons

    Quote Originally Posted by VictorN View Post
    What error do you get?
    this one

    1>c:\documents and settings\dellea\my documents\visual studio 2010\projects\resolve panel switcher\resolve panel switcher\Form1.h(563): error C2664: 'void System::Windows::Forms::Control::Text::set(System::String ^)' : cannot convert parameter 1 from 'char *' to 'System::String ^'
    1> No user-defined-conversion operator available, or
    1> Cannot convert an unmanaged type to a managed type

  4. #4
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: Strings in VC Form buttons

    Well, I guess you are not the first person getting this error message: https://www.google.de/search?q=C2664...hrome&ie=UTF-8
    Victor Nijegorodov

  5. #5
    Join Date
    May 2016
    Location
    Los Angeles
    Posts
    6

    Re: Strings in VC Form buttons

    Thank You. That advice fix it.
    Code:
    this->button1->Text = gcnew String(src_lev[1].src_name1);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured