2018년 11월 22일 목요일

[C#] ListBox Example



1. ListBox Example
1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Windows.Forms;

namespace WindowsFormsApp3
{
    class CsListBox
    {
        ListBox list;

        public CsListBox(EventHandler handler)
        {
            list = new ListBox();
            list.Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Left;
            list.Dock = DockStyle.Fill;
            list.Show();
            //list.Click += handler;
        }

        public ListBox get()
        {
            return list;
        }

        public void addItem(String text)
        {
            list.Items.Add(text);
        }

        public int getSelectedIndex(String text)
        {
            return list.SelectedIndex;
        }

        public String getSelectedText()
        {
            return list.Items[list.SelectedIndex].ToString();
        }

    }
}

댓글 없음:

댓글 쓰기