Oct 12, 2015

C# Basic ] Listview






I added Listview.

You can see just empty box.

You will add text and listview layout.

There are many way draw layout.

I use simply way.

1
2
3
4
5
6
7
public Form1()
        {
            InitializeComponent();
            listView1.View = View.Details;
            listView1.Columns.Add("No");
            listView1.Columns.Add("Record");
        }

Line 4~6 : Listview column  name.

First item 'No' is id number.

Second item 'Record' is timer or counter.

This is record button for display timer or counter.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
  private void button3_Click(object sender, EventArgs e)
        {
            if(timerCount!=0)
            {
                ListViewItem lv = new ListViewItem(recordCnt.ToString());
                lv.SubItems.Add(timerText.Text);
                listView1.Items.Add(lv);
                recordCnt++;
            }
        }

Line 5 : making 'ListViewItem' and input id information.

Line 6 : input timer of counter information.

Line 7 : display listview.

Line 8 : increase id.

1
listView1.Items.Clear();

This is clear listview.

Run


You can see List view column.

Press '시작'(Start) and '기록'(record) button.


You can see recording timer.

This is counter mode.


This is button '종료'(finish)


List view is clear.

No comments:

Post a Comment