tailieunhanh - Loading a Windows PictureBox with Images Stored by Access as OLE Objects
[ Team LiB ] Recipe Loading a Windows PictureBox with Images Stored by Access as OLE Objects Problem You need to display images from a Microsoft Access database in a PictureBox control. Solution Strip the OLE image header that Microsoft Access adds to the image. The sample code contains six event handlers | Team LiB Recipe Loading a Windows PictureBox with Images Stored by Access as OLE Objects Problem You need to display images from a Microsoft Access database in a PictureBox control. Solution Strip the OLE image header that Microsoft Access adds to the image. The sample code contains six event handlers Sets up the sample by filling a DataTable within a DataSet with the Categories table from the Microsoft Access Northwind sample database. The CategorylD CategoryName and Description fields are bound to TextBox controls. The BindingManagerBase is obtained for the Categories table in the DataSet a handler is attached to manage the PositionChanged event and that handler is called to position the display on the first record. Updates the PictureBox with the image for the current record. This event is raised when the Position property value changes. The CategorylD for the current record is obtained using the position information in the BindingManagerBase object. A Connection object and Command object are created and used to retrieve the Picture binary field for the category record into a Byte array. A MemoryStream object is created and the image written into it from the Byte array using an offset to strip the OLE image header. The static FromStream method of the class is used to load the image into the PictureBox from the MemoryStream. Move First Sets the current record of the bound controls to the first record by setting the Position property of the BindingManagerBase object to 0. Move Previous Sets the current record of the bound controls to the previous record by decrementing the Position property of the BindingManagerBase object by 1. Move Next Sets the current record of the bound controls to the next record by incrementing the Position property of the BindingManagerBase object by 1. Move Last Sets the current record of the bound controls to the .
đang nạp các trang xem trước