Fly to the sky & Return

c# tabcontrol 상에서 function key 분배하기 본문

프로그래밍/c# & VB 등

c# tabcontrol 상에서 function key 분배하기

낼은어떻게 2020. 2. 27. 18:10
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

여러 tab이 있는 경우  function key에 할당된 메소드를 다르게 설정하기 입니다.

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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace contralTAbFunKey_test
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.KeyPreview = true;
 
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("button1");
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            MessageBox.Show("button2");
        }
 
        private void KeyEvent(object sender, KeyEventArgs e) //Keyup Event 
        {
            if (e.KeyCode == Keys.F1)
            {
                button1.PerformClick();
            }
            else if  (e.KeyCode == Keys.F2)
            {
                button3.PerformClick();
            }
            else
                MessageBox.Show("No Function");
 
        }
 
        private void KeyEvent_2(object sender, KeyEventArgs e) //Keyup Event 
        {
            if (e.KeyCode == Keys.F1)
            {
                button2.PerformClick();
            }
            else if (e.KeyCode == Keys.F2)
            {
                button4.PerformClick();
            }
            else
                MessageBox.Show("No Function");
 
        }
 
        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (tabControl1.SelectedIndex == 0)
            {
                this.KeyUp += new System.Windows.Forms.KeyEventHandler(KeyEvent);
            }
            else
                this.KeyUp += new System.Windows.Forms.KeyEventHandler(KeyEvent_2);
        }
 
        private void button3_Click(object sender, EventArgs e)
        {
            MessageBox.Show("button3");
        }
 
        private void button4_Click(object sender, EventArgs e)
        {
            MessageBox.Show("button4");
        }
    }
}
 
cs