It is a customized ListBox object with a check box beside the selected item; it owns all ListBox features.
Examples
The following example shows how to create a LinsCheckedListBox object.
// lsImageList is an extend reference
ImageList lsImageList;
// Create a listbox object
LinsCheckedListBox listbox = new LinsCheckedListBox();
// Set the listbox’s image list to an existed image list
listbox.ImageList = lsImageList;
listbox.Items.Clear();
// Create a list item
LinsCheckedListItem item1 = new LinsCheckedListItem();
// This item is checked
Item1.CheckState = CheckState.Checked;
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
LinsCheckedListItem item2 = new LinsCheckedListItem();
// This item is unchecked
Item2.CheckState = CheckState.Unchecked;
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 ImageList ImageList { get; set; }
Remarks
Get or set the image list that contains the image displayed on this listbox.
§ Methods
1) public virtual int InsertBySort(
ref LinsCheckedListItem item )
Parameters
item
Type: LinsCheckedListItem
The item which is going to be inserted into the listbox.
Return
It returns the index of item.
Remarks
Insert item into the listbox. It will be sorted automatically.
2) public void Select(
int nStartIndex,
int nEndIndex )
Parameters
nStartIndex
Type: int
The start index of the items which will be selected.
nEndIndex
Type: int
The end index of the items which will be selected.
Remarks
Select all items between nStartIndex and nEndIndex.
No comments:
Post a Comment