By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,530 Members | 880 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,530 IT Pros & Developers. It's quick & easy.

How to access and modify TextBox text in a Visual c++ Express Forms app.?

P: 2
I am fairly new to C++ and need help with the following

I Created a Forms application in Visualc++ Express with a TextBox control

I now want to access that textbox and change its content programmatically.

I cannot seem to reference it in any way. I've tried many things but still keep getting compile errors

Most of the code is generated by VisualC++ including the initialization of the form. This works fine and puts the form up on screen when executed. But any code I've added to try and access the textbox generates compile errors.

If anyone could tell me what the basic overall code structure should be I would appreciate it. Thanks.
Oct 31 '10 #1
Share this Question
Share on Google+
3 Replies


P: 1
What errors? Show your code and maybe try this:
Expand|Select|Wrap|Line Numbers
  1. textBox1->Text = "TextBox Test Control";
Nov 1 '10 #2

P: 2
// TestBed3.cpp : main project file.

#include "stdafx.h"
#include "Form1.h"
#include <iostream>
using namespace TestBed3;

[STAThreadAttribute]

int main(array<System::String ^> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(fal se);

// Create the main window and run it
Application::Run(gcnew Form1());

textBox1->Text = "TextBox Test Control";

return 0;
}

I've inserted the line in main but these are the errors I get.

1>TestBed3.cpp(19): error C2065: 'textBox1' : undeclared identifier
1>TestBed3.cpp(19): error C2227: left of '->Text' must point to class/struct/union/generic type
1> type is ''unknown-type''
Nov 1 '10 #3

weaknessforcats
Expert Mod 5K+
P: 9,197
Expand|Select|Wrap|Line Numbers
  1. textBox1->Text = "TextBox Test Control";
Assumiong the code above works, where do you create textBox1? The compiler can't find your textbox.
Nov 3 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.