Class ListBox
List box control
public class ListBox : Control
- Inheritance
-
ListBox
- Inherited Members
- Extension Methods
Constructors
ListBox(Dialog)
Create a new list box control
public ListBox(Dialog parent)
Parameters
parent
Dialog
Fields
MainLayer
public const int MainLayer = 0
Field Value
SelectionLayer
public const int SelectionLayer = 1
Field Value
border
protected int border
Field Value
ctrlStyle
protected ListBoxStyle ctrlStyle
Field Value
isDragging
protected bool isDragging
Field Value
itemList
protected List<ListItem> itemList
Field Value
margin
protected int margin
Field Value
scrollWidth
protected int scrollWidth
Field Value
scrollbarControl
protected ScrollBar scrollbarControl
Field Value
selectedIndex
protected int selectedIndex
Field Value
selectedStarted
protected int selectedStarted
Field Value
selectionRect
protected Rectangle selectionRect
Field Value
textHeight
protected int textHeight
Field Value
textRect
protected Rectangle textRect
Field Value
Properties
CanHaveFocus
Can this control have focus
public override bool CanHaveFocus { get; }
Property Value
this[int]
Indexer for items in the list
public ListItem this[int index] { get; }
Parameters
index
int
Property Value
NumberItems
Number of items current in the list
public int NumberItems { get; }
Property Value
Style
Sets the style of the listbox
public ListBoxStyle Style { get; set; }
Property Value
Methods
AddItem(string, string, object)
Adds an item to the list box control
public void AddItem(string text, string tag, object data)
Parameters
Clear()
Removes all items from the control
public void Clear()
GetSelectedIndex(int)
For single-selection listbox, returns the index of the selected item. For multi-selection, returns the first selected item after the previousSelected position. To search for the first selected item, the app passes -1 for previousSelected. For subsequent searches, the app passes the returned index back to GetSelectedIndex as. previousSelected. Returns -1 on error or if no item is selected.
public int GetSelectedIndex(int previousSelected)
Parameters
previousSelected
int
Returns
GetSelectedItem()
Gets the selected item
public ListItem GetSelectedItem()
Returns
GetSelectedItem(int)
Gets the selected item
public ListItem GetSelectedItem(int previousSelected)
Parameters
previousSelected
int
Returns
HandleKeyboard(WindowMessage, IntPtr, IntPtr)
Called when the control needs to handle the keyboard
public override bool HandleKeyboard(WindowMessage msg, IntPtr wParam, IntPtr lParam)
Parameters
msg
WindowMessagewParam
IntPtrlParam
IntPtr
Returns
HandleMouse(WindowMessage, Point, IntPtr, IntPtr)
Called when the control should handle the mouse
public override bool HandleMouse(WindowMessage msg, Point pt, IntPtr wParam, IntPtr lParam)
Parameters
msg
WindowMessagept
PointwParam
IntPtrlParam
IntPtr
Returns
InsertItem(int, string, object)
Inserts an item to the list box control
public void InsertItem(int index, string text, object data)
Parameters
OnInitialize()
Initialize the scrollbar control here
public override void OnInitialize()
RaiseDoubleClickEvent(ListBox, bool)
Raises the double click event
protected void RaiseDoubleClickEvent(ListBox sender, bool wasTriggeredByUser)
Parameters
RaiseSelectionEvent(ListBox, bool)
Raises the selection event
protected void RaiseSelectionEvent(ListBox sender, bool wasTriggeredByUser)
Parameters
RemoveAt(int)
Removes an item at a particular index
public void RemoveAt(int index)
Parameters
index
int
Render(Device, float)
Called when the control should be rendered
public override void Render(Device device, float elapsedTime)
Parameters
device
DeviceelapsedTime
float
SelectItem(int)
Selects this item
public void SelectItem(int newIndex)
Parameters
newIndex
int
SetBorder(int, int)
Sets the border and margin sizes
public void SetBorder(int borderSize, int marginSize)
Parameters
SetScrollbarWidth(int)
Sets the scroll bar width of this control
public void SetScrollbarWidth(int width)
Parameters
width
int
SetSelected(string)
Sets the selected item by text
public void SetSelected(string text)
Parameters
text
string
UpdateRectangles()
Update the rectangles for the list box control
protected override void UpdateRectangles()
Events
DoubleClick
public event EventHandler DoubleClick
Event Type
Selection
public event EventHandler Selection