richtextbox

Hi,

Here's a simplified version of my program.

I have three files that run a WinForm app.

main.cpp, Form1.h and Text.h. The code for main.cpp is unaltered. Form1.h includes Text.h and has the following function call from Text.h in the richtextbox code section (note. the name of the richtextbox in Form1 is called RichTextBox1):

Form1.h:
 
insertText(RichTextBox1);


Text.h:
1
2
3
4
void insertText(System::Windows::Forms::RichTextBox^ richtextbox){
    richtextbox->Text = L"Text goes here";
    richtextbox->SelectionColor = Color::Red;
}


The following is the error statement:
error C2653: 'Color' : is not a class or namespace name

error C2065: 'Red' : undeclared identifier

If the code line 'richtextbox->SelectionColor = Color::Red;' is placed after the insertText(RichTextBox1) in Form1.h, the program compiles without error.

My question:
How do I go about having 'richtextbox->SelectionColour = Color::Red' work in Text.h? That is, I want all text manipulation coming from Text.h with a single function call.

Any help / suggestions would be appreciated!
Last edited on
Hi,

I realised my error while doing the dishes of all things.

The above coding works providing:

using namespace System::Drawing;

is placed between Text.h's include guards and insertText function.

An obvious thing to code if you've got reasonable programming experience. Not so for a beginner like me ;).

Thanks,
Topic archived. No new replies allowed.