views:

52

answers:

1

Hi,

i have an image list, i am drawing it on form list-control. i will get image bounds when the images gets added to list. and it will come to draw-event there i get bounds. instead how to get the bounds width and height at form-load.. i mean before drawing. how to calculate it?.

i am using .net3.5 CF framework

A: 

Assuming you are using a list view control and the imagelist property then you can use

ListView.ImageList.ImageSize, although I don't think that this changes automatically depending on the images you add, docs suggest it defaults to 16x16, so you will have to set it I guess.

You don't say how you are loading the images, do you set the imagelist items at design time? Or do you load them from files at runtime? If you load them at runtime you can get the image size info from the file as you load it.

Matt
yes, actually i do set the image size at beginning itself,if we need to change the bounds at run-time based on resolution of device, just we need to multiply the image size with the scale-factor. we get the correct bound which fit for the resolution.we can get scale-factor at the beginning only for that we need to override override ScaleControl function.
Shadow
You can also get the scale factor any time by using Graphics.DpiX and Graphics.DpiY. E.g. Graphics.DpiX / 96.0f will give you the horizontal scale factor.
Matt