Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++
|
Visual C++ Questions specific to Microsoft's Visual C++. For questions not specific to this Microsoft version, use the C++ Programming forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual C++ section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 17th, 2010, 01:00 AM
Registered User
 
Join Date: May 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Retrieving data elements from inside an ArrayList Class

I've created a class PulldownArray, which contains two strings Value and Description. I created an array of this class called PulldownTABLE with the ArrayList^ command in my main program and I then populate it with the .Add method. All this works fine.

How do I retrive the Value and Description strings for an individual item in PulldownTABLE?

Code:
public ref class PulldownArray{
	public:
		String^ myValue;
		String^ myDescription;
	public:
		~PulldownArray(){
		}
		PulldownArray( String^ strValue, String^ strDescription ){
			this->myValue = strValue;
			this->myDescription = strValue + " \t " + strDescription;
		}
	property
		String^ Value{
			String^ get(){
			return myValue;
			}
		}
	property
		String^ Description{
			String^ get(){
				return myDescription;
			}
	   }
	virtual 
		String^ ToString() override{
		   return this->myValue;
	    }
};


main{.....

String^ ReturnString;

ArrayList^ PulldownTABLE = gcnew ArrayList;
PulldownTABLE->Add(gcnew PulldownArray("TABLE1", "TABLE1_description"));
PulldownTABLE->Add(gcnew PulldownArray("TABLE2", "TABLE2_description"));

//Works, but I don't want to have to write overrides for every element
ReturnString = PulldownTABLE[1]->ToString();
//Can see both myDescription and Description in the debugger but these both fail at compile
ReturnString = PulldownTABLE[1]->myDescription;
ReturnString = PulldownTABLE[1]->Description();
...
}

Any help would be appreciated but please keep it simple as I'm particularily stupid and ignorant.





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to retrieve the data(ArrayList) from JSP to Action Class cesarv JSP Basics 0 December 2nd, 2009 05:15 AM
problem retrieving data processed by class library maricar C# 0 October 23rd, 2008 10:27 PM
Arraylist::Sort() by class member jilly Visual C++ 2005 0 March 22nd, 2006 06:49 PM
Retrieving list of tables inside a database... vb_developer SQL Server ASP 6 September 13th, 2004 10:47 AM
Hiding elements using identification by class jacob Javascript How-To 4 February 2nd, 2004 03:52 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.