Hi Sanjeeva !
Please use the 'Reply Group' button of your news reader. It allows the chain
of messages to stay under the same topic, and following the discussion
becomes a whole lot easier.
Like I stated in my post, "gcnew" keyword is defined only in C++/CLI
context. This means that if you are using Visual Studio 2005 Beta, the
keyword will work and will do what it is supposed to do. In earlier
versions, it does not work, as C++/CLI is not supported yet.
What "gcnew" does is reserve memory for a new managed object on the heap. In
Managed C++, the equivalent is "new", I think. So, the call should look
like:
MyListView->LargeImageList->ImageSize = new System::Drawing::Size(100,100);
In the documentation, it says that when you set a new image size, the handle
is recreated. This means that you must order the listview to redraw itself.
If this does not work, then the only possibility is to create a copy of the
old imagelist with a new size property, then replace the old list, like
here: (This is Managed C++ code)
<snip starts>
// Somewhere at the begin of file, to avoid lots of typing
using System::Windows::Forms;
// Later in the file, where you need to change the imagelist size.
ImageList* pOldList = MyListView->LargeImageList;
ImageList* pNewList = new ImageList();
pNewList->ImageSize = new System::Drawing::Size(100, 100);
// Other setup for the new image list, like color depth and transparency, if
required.
IEnumerator* pOldListEnum = pOldList->Images->GetEnumerator();
pNewList->Images->Add( __try_cast<Bitmap*> (pOldListEnum->Current()) );
while ( pOldListEnum->MoveNext() )
pNewList->Images->Add( __try_cast<Bitmap*> (pOldListEnum->Current()) );
// The new image list is now a copy of the old one, with new image size set.
// Now we put it into the place of the old one
MyListView->LargeImageList = pNewList;
// The old one is discarded by the Garbage Collection at some point.
<snip ends>
I am not 100% certain that this approach will work. The idea is to create a
new imagelist, set a new size for it, and then systematically add the images
from the old list into the new list by using an enumerator to the old list.
Again, it is not certain whether ImageList::Images::Add will create a copy
of the image you add to it. This shouldn't make a difference in Managed C++,
though. However, it's a point that should be noted. So, do not use the code
snip blindly without examining it first, and debugging through it properly
to see if it REALLY works. I haven't tested it, so I do not know.
-Antti Keskinen
"Sanjeeva Reddy" <sanjeeva.reddy at yahoo no mail.com> wrote in message
news:Oc**************@TK2MSFTNGP10.phx.gbl...
hai Anti Keskinen,
i have used
the following code MyListView->LargeImageList->ImageSize = gcnew
System::Drawing::Size(100,
100); // Sets large image size to 100, 100
here i am getting error like "gcnew is undeclared error",how to deeclare
'gcnew"
and when i am using in runtime to change the size of images in imagelist
in
listview control in .net(forms application) by chnging one trckbar(like
tb1->Value),
the imagelist is disappearing,and if again i added images to that
imagelist
the images r adding as currentimage size.
pls tell me how to change the size in runtime without destroying the
images.
Thanks and Regards, Sanjeev