LinsListBox class

      It is a customized ListBox object; it owns all ListBox features. This listbox allow users to associate an icon or image with any listed item.

Examples

The following example shows how to create a LinsListBox object.

 

// lsImageList is an extend reference

ImageList lsImageList;

 

// Create a listbox object

LinsListBox listbox = new LinsListBox();

// Set the listbox’s image list to an existed image list

listbox.ImageList = lsImageList;

 

listbox.Items.Clear();

 

// Create a list item

LinsListItem item1 = new LinsListItem();

Item1.ID = 1;

// item text

Item1.Text = “Red”;

// the icon associated with this item will be the first image in lsImageList                  

Item1.ImageIndex = 0;                    

listbox.Items.Add( item1 );

           

// Create second list item

LinsListItem item2 = new LinsListItem();

Item2.ID = 2;

// item text

Item2.Text = “Gold”;   

// the icon associated with this item will be the second image in lsImageList            

Item2.ImageIndex = 1;                    

listbox.Items.Add( item1 );

 

//set the first one as default selected

listbox.SelectedIndex = 0;

 

§      Members

1)   public bool ShowIcon { get; set; }               

Remarks

Get or set the flag which controls whether to show the icon for each item.

 

§      Methods

1)   public void UpdateImage(

int nImageIndex,

ref Image newImage )             

Parameters

nImageIndex

Type: int

The index of the image which is going to be replaced.

 

newImage

Type: Image

The new image.

 

Remarks

Replace the image with newImage.

 

2)   public void ResetImageList()               

Remarks

Clear the image list.

 

3)   public void SetImageList(

ref ImageList lsImageList )              

Remarks

Set the image list that contains the image displayed on this listbox. If user uses this call to set the image list, then user should free the resource allocated in lsImageList themself

 

4)   public ImageList GetImageList()            

Remarks

Get the image list that contains the image displayed on this listbox.

 

5)   public int AddImage(

Icon icon)             

Parameters

icon

Type: Icon

The icon which is going to be added into the image list.

 

Return

It returns the index of icon.

 

Remarks

Add icon into the image list that contains the image displayed on this listbox. It returns the index of icon.

 

6)   public int AddImage(

Image image)                 

Parameters

image

Type: Image

The image which is going to be added into the image list.

 

Return

It returns the index of image.

 

Remarks

Add image into the image list that contains the image displayed on this listbox. It returns the index of image.

 

7)   public virtual void SelecteThisOneOnly(

int nIndex)                 

Parameters

nIndex

Type: int

The index of the item which will be the only selected item.

 

Remarks

Make sure that the nIndex item is the only one selected.