ImageList control in Compact Framework.
-
Hi all! In a my Compact Framework application that I'm developing using V.S. 2005 and VB, I need to choose a .bmp image file. If I do this work using the "classic" OpenFileDialog, all is OK and easy, but I desire to choose the file directly from a list of icons instead from the FileName. What control allow to do it? ImageList, ListView or ListBox? I tryed to use both together ImageList and ListView, but I encoutered in its use some limitations respect .Framework possibilities. The below line produces an error because the property "FromFile" is not present in Compact Framework and then I am not able to assign the string path-filename of image I want add in ImageList1. I tryed other ways but without success. ImageList1.Images.Add(Image.FromFile("image-path")) Thanks for help
-
Hi all! In a my Compact Framework application that I'm developing using V.S. 2005 and VB, I need to choose a .bmp image file. If I do this work using the "classic" OpenFileDialog, all is OK and easy, but I desire to choose the file directly from a list of icons instead from the FileName. What control allow to do it? ImageList, ListView or ListBox? I tryed to use both together ImageList and ListView, but I encoutered in its use some limitations respect .Framework possibilities. The below line produces an error because the property "FromFile" is not present in Compact Framework and then I am not able to assign the string path-filename of image I want add in ImageList1. I tryed other ways but without success. ImageList1.Images.Add(Image.FromFile("image-path")) Thanks for help
-
You could try this Dim b as bitmap = new bitmap("image-path") imagelist1.images.add(b) b.Dispose() If you dim a bitmap you must dispose of it when you have finished. Hope this helps.
Hi Funklet, Previously I already tried your suggest, but now I tried again: Dim Bmp As Bitmap = New Bitmap("\Storage Card\Agip.bmp") ImageList1.Images.Add(Bmp) Bmp.Dispose() When I launck the appl. through simulator, V.S. 2005 stop the running, and return me these series of Error: 1) - In Immediate Window: A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll A first chance exception of type 'System.NullReferenceException' occurred in System.Windows.Forms.dll 2) - In Form2.Designer.vb at row: Me.ImageList1.Images.Add(CType(resources.GetObject("resource"), System.Drawing.Image)): System.NullReferenceException was unhandled Message="NullReferenceException" StackTrace: at ImageCollection.Add() at TrackPlotter.Form2.InitializeComponent() at TrackPlotter.Form2..ctor() at System.Reflection.RuntimeConstructorInfo.InternalInvoke() at System.Reflection.RuntimeConstructorInfo.Invoke() at System.Reflection.ConstructorInfo.Invoke() at System.Activator.CreateInstance() at MyForms.Create__Instance__() at MyForms.get_Form2() at TrackPlotter.Form1.Button1_Click() at System.Windows.Forms.Control.OnClick() at System.Windows.Forms.Button.OnClick() at System.Windows.Forms.ButtonBase.WnProc() at System.Windows.Forms.Control._InternalWnProc() at Microsoft.AGL.Forms.EVL.EnterMainLoop() at System.Windows.Forms.Application.Run() at TrackPlotter.Form1.Main() And suggest me: 1) Use the "New" Keyword to create an Object Instance. 2) Check to determine if the Object is Null before calling the metod. 3) Get the General Help for this exception.
-
Hi Funklet, Previously I already tried your suggest, but now I tried again: Dim Bmp As Bitmap = New Bitmap("\Storage Card\Agip.bmp") ImageList1.Images.Add(Bmp) Bmp.Dispose() When I launck the appl. through simulator, V.S. 2005 stop the running, and return me these series of Error: 1) - In Immediate Window: A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll A first chance exception of type 'System.NullReferenceException' occurred in System.Windows.Forms.dll 2) - In Form2.Designer.vb at row: Me.ImageList1.Images.Add(CType(resources.GetObject("resource"), System.Drawing.Image)): System.NullReferenceException was unhandled Message="NullReferenceException" StackTrace: at ImageCollection.Add() at TrackPlotter.Form2.InitializeComponent() at TrackPlotter.Form2..ctor() at System.Reflection.RuntimeConstructorInfo.InternalInvoke() at System.Reflection.RuntimeConstructorInfo.Invoke() at System.Reflection.ConstructorInfo.Invoke() at System.Activator.CreateInstance() at MyForms.Create__Instance__() at MyForms.get_Form2() at TrackPlotter.Form1.Button1_Click() at System.Windows.Forms.Control.OnClick() at System.Windows.Forms.Button.OnClick() at System.Windows.Forms.ButtonBase.WnProc() at System.Windows.Forms.Control._InternalWnProc() at Microsoft.AGL.Forms.EVL.EnterMainLoop() at System.Windows.Forms.Application.Run() at TrackPlotter.Form1.Main() And suggest me: 1) Use the "New" Keyword to create an Object Instance. 2) Check to determine if the Object is Null before calling the metod. 3) Get the General Help for this exception.
I'm not sure how you are including the image in your project but I would use 'Add Existing Item' to add the image to your project and ensure 'Copy Always' or 'Copy If Newer' is in the properties of the file. Also consider using:
ImageList1.Images.Add(new Bitmap("\Program Files\(Your Project Name)\Agip.bmp))
This way you can eliminate other factors such as a problem with the Storage Card... You may need to dispose of the Bitmaps when the form is disposed rather than immediately... Hope this helps.
-
I'm not sure how you are including the image in your project but I would use 'Add Existing Item' to add the image to your project and ensure 'Copy Always' or 'Copy If Newer' is in the properties of the file. Also consider using:
ImageList1.Images.Add(new Bitmap("\Program Files\(Your Project Name)\Agip.bmp))
This way you can eliminate other factors such as a problem with the Storage Card... You may need to dispose of the Bitmaps when the form is disposed rather than immediately... Hope this helps.
Thank you very much funklet, Your first code now works! I noted also Dim B As Image = New Bitmap ("image-path") works correctly.