-
Notifications
You must be signed in to change notification settings - Fork 4
/
Search.cs
72 lines (66 loc) · 2.71 KB
/
Search.cs
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
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 SimplyMorpher
{
public partial class Search : Form
{
Form1 myparent;
public Search(Form1 myparent)
{
InitializeComponent();
this.myparent = myparent;
}
private void Search_ResizeEnd(object sender, EventArgs e)
{
txtName.Size = new Size(this.Size.Width - btnSearch.Size.Width - 30, txtName.Size.Height);
btnSearch.Location = new Point(this.Size.Width - btnSearch.Size.Width - 15, btnSearch.Location.Y);
listView1.Size = new Size(listView1.Size.Width, this.Size.Height - 65);
listView1.Columns[1].Width = listView1.ClientSize.Width - listView1.Columns[0].Width;
}
private void Search_Load(object sender, EventArgs e)
{
txtName.Size = new Size(this.Size.Width - btnSearch.Size.Width - 30, txtName.Size.Height);
btnSearch.Location = new Point(this.Size.Width - btnSearch.Size.Width - 15, btnSearch.Location.Y);
listView1.Size = new Size(listView1.Size.Width, this.Size.Height - 65);
listView1.Columns[1].Width = listView1.ClientSize.Width - listView1.Columns[0].Width;
listView1.Activation = ItemActivation.TwoClick;
listView1.ItemActivate += ListView1_ItemActivate;
}
private void btnSearch_Click(object sender, EventArgs e)
{
listView1.Items.Clear();
if (txtName.TextLength > 1)
{
for (int i = 0; i < DisplayDB.DisplayName.Length; i++)
{
if (DisplayDB.DisplayName[i].Contains(txtName.Text))
{
ListViewItem newrow = new ListViewItem(DisplayDB.DisplayID[i].ToString());
newrow.SubItems.Add(DisplayDB.DisplayName[i]);
listView1.Items.Add(newrow);
}
}
}
if (listView1.ClientSize.Width - listView1.Columns[0].Width - listView1.Columns[1].Width < 1)
listView1.Columns[1].Width = listView1.ClientSize.Width - listView1.Columns[0].Width;
}
private void ListView1_ItemActivate(Object sender, EventArgs e)
{
myparent.textBox2.Text = listView1.SelectedItems[0].Text;
}
private void txtName_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == Convert.ToChar(Keys.Return))
{
btnSearch_Click(sender, e);
}
}
}
}