^Johnny2Bad
July 13th, 2007, 07:32 PM
This should be a quickie...
As per the following code
int IPv4Control::ReturnIndexOfName(String ^Name)
{
int Index=0;
int Result=-1;
dataBox^ dbCurr;
dbCurr=gcnew dataBox();
for each (Object^ currObj in this->Controls)
{
if (currObj->GetType()==dbCurr->GetType())
{
dbCurr=(dataBox^) currObj;
if (Name==dbCurr->Name)
{
Result=Index;
break;
}
}
Index++;
}
return Result;
}
I am iterating through the controls collection of the current windows form looking for all the "dataBoxes", which when found are examined too see if the name matches the String^ Name. My problem with this is I have too create a dummy databox (dbCurr) with gcnew in order to access the GetType for that object which apart from that does not get used.
Is there another way too get the dataBox type without creating a databox, so I can save some memory and the code ultimately does not look sloppy.
Cheers,
Jonathan.
As per the following code
int IPv4Control::ReturnIndexOfName(String ^Name)
{
int Index=0;
int Result=-1;
dataBox^ dbCurr;
dbCurr=gcnew dataBox();
for each (Object^ currObj in this->Controls)
{
if (currObj->GetType()==dbCurr->GetType())
{
dbCurr=(dataBox^) currObj;
if (Name==dbCurr->Name)
{
Result=Index;
break;
}
}
Index++;
}
return Result;
}
I am iterating through the controls collection of the current windows form looking for all the "dataBoxes", which when found are examined too see if the name matches the String^ Name. My problem with this is I have too create a dummy databox (dbCurr) with gcnew in order to access the GetType for that object which apart from that does not get used.
Is there another way too get the dataBox type without creating a databox, so I can save some memory and the code ultimately does not look sloppy.
Cheers,
Jonathan.