Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / July 2006

Tip: Looking for answers? Try searching our database.

Cannot write to a richtextbox control from outside

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
havish14@gmail.com - 21 Jun 2006 21:29 GMT
Hello guys,

I'm just a newbie as far as VS2005 and winforms go, so please bear with
me on this question. I'm implementing a windows forms application that
has tab controls and one of the tabpage containing a rich text box. I
have a public function in "Form1.h" that takes in a string as input and
outputs it to the text box.

public:

     property String^ AppendValue // PassedValue property
     {
        void set(String ^value)
       {
           // MessageBox::Show(value, "test", MessageBoxButtons::OK,
MessageBoxIcon::Information);
           AppendText(value);

        }
     }

Now, I have a main.cpp file that runs this Form1 application. I have
this function in main.cpp that does some test matrix generation work
and then needs to output its results to this text box. Here is that
function -

void SendOutput(String^ rstr)
{
   Form1 myObj;
   myObj.AppendValue::set(rstr);
}

The problem is "rstr" doesnt get displayed on the output text box. I
have included the namespace from Form1 and everything compiles fine
too. I just cant seem to figure out whats going wrong. Could anybody
please help me understand how to fix this problem??

I'm guessing it has something to do with creating the correct instance
of Form1. Thoughts anybody??

Thanks in advance!!
Dave Sexton - 08 Jul 2006 02:44 GMT
Hi Havish,

Could it be a Threading issue?  Make sure you use Form1.Invoke if you are
calling SendOutput from a non-UI thread.

What does your AppendText method do?  The problem could be in that method.

> I'm guessing it has something to do with creating the correct instance
> of Form1. Thoughts anybody??

How many instances of Form1 are created in code?  It should probably be just
one, I'd imagine.

HTH

> Hello guys,
>
[quoted text clipped - 37 lines]
>
> Thanks in advance!!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.