Search code examples
winformstextboxc++-clivisual-c++-2010

display data from a 2d array of char in text box C++/CLI


I have a 2d char array i.e. char myarray[5][5], I need to display the characters in a series of textboxes on the form application. There are two issues here:

  1. The array is constructed by an external function, not a part of the public ref class form1 and i need to call the function of display which has to be defined inside form1 to access textboxes from the external function.

  2. Even if i'm able to do that how do i display char in textboxes? It seems to accept only Sytem String^ type data.


Solution

  • I have reached the following conclusions (these might not be the ideal or good programming practices, but since no one has answered yet I'll tell how to get this through):-

    1. Set a global variable. Store the processed data in it.
    2. Access this data from Form1.
    3. Convert data from string to System::String^ using gcnew

      String^ myarray_str = gcnew String(myarray);