A
alan.chambers
I am new to C++/CLI. I want to do a very simple thing. In other C++
applications, my forms have always been 'context free' in the sense
that I pass them a temporary copy of the data for them to display and
munge about. If OK is pressed, the client of the form does something
with the temporary data. This approach is surely a commonplace, and I
have implemented it in real C++ something like this:
AddressData temp(original); // original could be of type AddressData,
perhaps an element in
// a vector of addresses .
AddressForm form;
if (form.Execute(temp))
{
// OK was pressed.
original = temp; // or whatever is approriate
}
bool Form::Execute(AddressData& data)
{
// populate controls from data.
bool result = ShowDialog() == DialogResult::OK;
if (result)
{
// populate data from controls.
}
}
Now, in .NET-land it seems that everything is a reference, including
so-called value types if they are added to an array. What is the usual
approach to data handling in .NET GUI design? I want to protect my data
from direct manipulation by forms, and to avoid the client of the form
knowing anything about it's implementation (e.g. all those public
controls used in MFC code).
Thanks.
UnicycleGuy
applications, my forms have always been 'context free' in the sense
that I pass them a temporary copy of the data for them to display and
munge about. If OK is pressed, the client of the form does something
with the temporary data. This approach is surely a commonplace, and I
have implemented it in real C++ something like this:
AddressData temp(original); // original could be of type AddressData,
perhaps an element in
// a vector of addresses .
AddressForm form;
if (form.Execute(temp))
{
// OK was pressed.
original = temp; // or whatever is approriate
}
bool Form::Execute(AddressData& data)
{
// populate controls from data.
bool result = ShowDialog() == DialogResult::OK;
if (result)
{
// populate data from controls.
}
}
Now, in .NET-land it seems that everything is a reference, including
so-called value types if they are added to an array. What is the usual
approach to data handling in .NET GUI design? I want to protect my data
from direct manipulation by forms, and to avoid the client of the form
knowing anything about it's implementation (e.g. all those public
controls used in MFC code).
Thanks.
UnicycleGuy