-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathForm2.cs
More file actions
93 lines (85 loc) · 3.34 KB
/
Form2.cs
File metadata and controls
93 lines (85 loc) · 3.34 KB
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
84
85
86
87
88
89
90
91
92
93
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 Api_test01
{
public partial class Child : Form
{
Parent parent;
string name;
string code;
public Child(Parent form1)
{
InitializeComponent();
parent = form1;
추가02_btn.Enabled = false;
종목검색_datagridview.SelectionChanged += SendInfo;
}
public void SendInfo(object sender, EventArgs e)
{ // 종목검색에서 나온 종목을 고르면, 그 종목의 정보를 table에 간략하게 출력함
if (sender.Equals(종목검색_datagridview))
{
try
{
if (종목검색_datagridview.SelectedCells.Count > 0)
{
int selectRowindex = 종목검색_datagridview.SelectedCells[0].RowIndex;
if (selectRowindex == 0 && 종목검색_datagridview.Rows.Count == 1 && 종목검색_datagridview["종목검색_이름", selectRowindex].Value == null)
{ // 처음에 빈 셀이 선택되서 오류나는 것을 방지함
종목검색_datagridview.ClearSelection();
return;
}
name = 종목검색_datagridview["종목검색_이름", selectRowindex].Value.ToString();
code = 종목검색_datagridview["종목검색_코드", selectRowindex].Value.ToString();
parent.send_info_parent(name, code);
추가02_btn.Enabled = true;
종목이름02_label.Text = name;
}
}
catch (Exception ex)
{
// 오류나도 속행한다.
}
}
}
private void 검색_btn_Click(object sender, EventArgs e)
{
// 현재는 1개만 검색에 나오게 함
if (검색_txtBox.Text == "") { return; }
종목검색_datagridview.Rows.Clear();
int i = 0, j = 0;
foreach (string name in parent.all_Name)
{
if (name.IndexOf(검색_txtBox.Text, 0, name.Length) != -1)
{
종목검색_datagridview.Rows.Add(); // datagrid 행 추가
종목검색_datagridview["종목검색_이름", j].Value = name;
종목검색_datagridview["종목검색_코드", j].Value = parent.all_Code[i];
//종목검색_datagridview["종목검색_현재가", j].Value = parent.현재가[i];
j++;
}
i++;
}
}
private void 추가02_btn_Click(object sender, EventArgs e)
{
if (종목검색_datagridview.SelectedCells.Count > 0)
{
parent.add_grid(name, code);
}
}
private void 검색_txtBox_KeyDown(object sender, KeyEventArgs e) //엔터키 입력시 검색
{
if(e.KeyCode == Keys.Enter)
{
검색_btn_Click(sender, e);
}
}
}
}