TAILIEUCHUNG - Displaying an Image from a Database in a Windows Forms Control

[ Team LiB ] Recipe Displaying an Image from a Database in a Windows Forms Control Problem You need to display an image from a database in a Windows Forms control. Solution Read the image into a byte array and load it directly into a PictureBox control with a MemoryStream. | Team LiB Recipe Displaying an Image from a Database in a Windows Forms Control Problem You need to display an image from a database in a Windows Forms control. Solution Read the image into a byte array and load it directly into a PictureBox control with a MemoryStream. The sample code contains six event handlers Sets up the sample by filling a DataTable within a DataSet with the Employees table from the Northwind sample database. The EmployeelD LastName and FirstName fields are bound to TextBox controls. The BindingManagerBase is obtained for the Employees 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 EmployeelD 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 Photo binary field for the employee record into a Byte array. A MemoryStream object is created from the Byte array. 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 last record by setting the Position property of the BindingManagerBase object to the total .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.