Technological Guide.

C#2008 How to show images in ListView from Database

Thursday, August 13th, 2009

Being programmers you may get requirement to handle with images to save to database and load them into ListView container. I’m presenting a code snippet in Visual C# 2008 which can be downloaded and can be tested on your end for the ListView items with images retrieved and updated back to the database.

Features:

  • Allows to select image using OpenDialog.
  • You can save to database which will be an Access 2003 mdb file located in \bin\Debug folder.
  • You can retrieve images using Retrieve Images button.
  • You can remove image using Remove button which will remove image from database directly.

Requirements:

  • Visual C# 2008 with Microsoft .Net Framework 3.5

You can download from ListViewImgDb and use the rar file using the password: lsv123

Color Selector

Wednesday, June 24th, 2009
Color Selector is a small application developed in Visual C# which displays all named color along with a small strip of the color. Upon selecting the color the below panel will be updated with the selected color. As shown in the 2 images.

The DrawItem event of the combo box control has to be implemented in the code and DrawMode property for the combo box control must be set to OwnerDrawFixed in design time in order to let the DrawItem event work.

Design & Coding Application:

Create a Visual C# Windows Forms project in either Visual Studio 2005 / 2008 with Single Form which contains a button (btnLoadColorList), combo box(cmbColorList) and panel (pnlColorTester). Set the DrawMode property of cmbColorList to OwnerDrawFixed and DropDown height property of cmbColorList to 80.

Code for the Form will be as follows.

You can download the sample application developed in Visual Studio 2008 from here.