Hi guys,
I was hoping someone could explain to me how I would go about grabbing a pointer/reference to my variable 'textName' contained within the Reports class, (some code omitted to try to simplify the scenario)
//Reports.h
class Reports : public wxPanel
{
public:
void AddStudent(wxCommandEvent & event);
wxTextCtrl *textName; // declare variable
};
//Reports.cpp
Reports::Reports(wxPanel * parent)
: wxPanel(parent, wxID_ANY, wxPoint(-1, -1), wxSize(500, 500))
{
wxTextCtrl *textName = new wxTextCtrl(this, wxID_AddStudent, wxT(""), wxPoint(65, 65));
}
void Reports::AddStudent(wxCommandEvent & WXUNUSED(event))
{
// The following breaks the code, I want to grab textName
textName.SetValue("Test");
textName.SetFocus();
/* *************************
If I re-create textName then access (as shown in the following
commented code) then it works fine but I can't
work out how to create a pointer/reference to the
previous textName rather than having to re-create one!
wxTextCtrl *textName = new wxTextCtrl(this,wxID_AddStudent, wxT("Another button..."), wxPoint(65, 95));
textName->SetValue("Testing");
textName->SetFocus();
*******************************/
}