wListBox.cs
using System; using System.Drawing; using System.Windows.Forms; public class WListBox : WCtrl { ListBox listbox; public ListBox lb { get { return listbox; } } public WListBox( String[] items, EventHandler handler, int size ) : base(size) { ctrl = listbox = new ListBox(); SetFontSize(size); anchorAll(); dockFill(); if( items != null ) { for( int i = 0; i < items.Length; i++ ) { listbox.Items.Add( items[i] ); } } if( handler != null ) { listbox.Click += handler; } //listbox.Show(); } public WListBox( String[] items, EventHandler handler ) : this(items,handler,0) {} public WListBox( String[] items ) : this(items,null,0) {} public WListBox( String[] items, int size ) : this(items,null,size) {} public WListBox( EventHandler handler) : this(null,handler,0) {} public WListBox( EventHandler handler, int size) : this(null,handler,size) {} public WListBox( int size) : this(null,null,size) {} public WListBox() : this(null,null,0) {} public void AddItem(String text) { listbox.Items.Add(text); } public int getSelectedIndex() { return listbox.SelectedIndex; } public String getSelectedText() { return listbox.Items[listbox.SelectedIndex].ToString(); } public void selectFirstItem() { if( listbox.Items.Count > 0 ) listbox.SelectedIndex = 0; } public void SetEventHandler(EventHandler handler) { if( handler != null ) { listbox.Click += handler; } } }
댓글 없음:
댓글 쓰기