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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
 
namespace WPA08
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            textBox1.Focus();
        }
 
        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                listBox1.Items.Add("아이템 " + textBox1.Text);
                textBox1.Text = "";
            }
        }
 
        // ListBox 선택시 호출
        private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
 
            int nSel = listBox1.SelectedIndex;
            if (nSel < 0 || nSel >= listBox1.Items.Count)
                return;
 
            listBox1.SelectedIndex = -1;
             
            string strText = listBox1.Items[nSel].ToString();
            string strOut1 = string.Format("선택한 라인은 '{0}'입니다.", nSel + 1);
            string strout2 = string.Format("'{0}'를 삭제합니다.", strText);
            string strout = strOut1 + strout2;
             
            MessageBoxResult nRes;
            nRes = MessageBox.Show(strout, "선택삭제", MessageBoxButton.OKCancel);
 
            if (nRes == MessageBoxResult.OK)
                listBox1.Items.RemoveAt(nSel);
        }
    }
}

'프로그래밍 > WindowsPhone' 카테고리의 다른 글

IsolatedStorageFile  (0) 2011.07.06
화면회전  (0) 2011.07.05
시계표시  (0) 2011.07.04
Timer  (0) 2011.07.04
동의대 앱창작센터  (0) 2011.07.01
Posted by 건깡