制作一个简单的通讯录,求指导如何进行信息查询
我是个新手,刚学的C#程序代码:
[color=#0000FF]usingSystem; using System.Collections.Generic; using using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace AddressListExample { public partial class UpdateFriends : Form { public UpdateFriends() { InitializeComponent(); } public bool ValidateInput() { if(this.textBox1.Text.Trim().Equals("")) { MessageBox.Show("请输入姓名!"); this.textBox1.Focus(); return false; } if(this.comboBox1.Text.Trim().Equals("")) { MessageBox.Show("请选择性别!"); return false; } if(this.textBox2.Text.Trim().Equals("")) { MessageBox.Show("请输入电话!"); this.textBox2.Focus(); return false; } if(this.textBox3.Text.Trim().Equals("")) { MessageBox.Show("请输入联系地址!"); this.textBox3.Focus(); return false; } if(this.comboBox2.Text.Trim().Equals("")) { MessageBox.Show("请选择组别!"); this.comboBox2.Focus(); return false; } if(this.pictureBox1.Image.Equals("")) { MessageBox.Show("请选择头像!"); this.pictureBox1.Focus(); return false; } return true; } private void change_Click(object sender, EventArgs e) { changeHead changehead = new changeHead(); changehead.ShowDialog(); this.pictureBox1.Image = InfoHelper.imageIndex != -1 ? this.ilPhotos.Images[InfoHelper.imageIndex] : null; } public void RefreshListView() { this.LvFriends.Items.Clear(); for (int i = 0; i < InfoHelper.friendsCount; i++) { ListViewItem lvi = new ListViewItem(); lvi.Text = InfoHelper.frinedsName[i]; lvi.ImageIndex = InfoHelper.friendsImageIndex[i]; this.LvFriends.Items.Add(lvi); } } private void button1_Click(object sender, EventArgs e) { if (this.ValidateInput()) { ListViewItem lvi = new ListViewItem(); lvi.SubItems[0].Text = this.textBox1.Text.Trim(); lvi.SubItems.Add(this.comboBox1.Text.Trim()); lvi.SubItems.Add(this.textBox2.Text.Trim()); lvi.SubItems.Add(this.textBox3.Text.Trim()); lvi.SubItems.Add(this.comboBox2.Text.Trim()); lvi.ImageIndex = InfoHelper.imageIndex; MessageBox.Show("增加成功!"); this.LvFriends.Items.Add(lvi); ClearTextBox(); } } public void ClearTextBox() { this.textBox1.Text=" "; this.textBox2.Text=" "; this.textBox3.Text=" "; this.comboBox1.Text=""; this.comboBox2.Text=""; this.pictureBox1.Image = null; } private void button3_Click(object sender, EventArgs e) { if(this.LvFriends.SelectedItems.Count!=0) { this.LvFriends.Items.Remove(this.LvFriends.SelectedItems[0]); MessageBox.Show("删除成功!"); ClearTextBox(); } } private void button2_Click(object sender, EventArgs e) { if(this.LvFriends.SelectedItems.Count!=0&&this.ValidateInput()) { this.LvFriends.SelectedItems[0].SubItems[0].Text=this.textBox1.Text; this.LvFriends.SelectedItems[0].SubItems[1].Text = this.comboBox1.Text; this.LvFriends.SelectedItems[0].SubItems[2].Text = this.textBox2.Text; this.LvFriends.SelectedItems[0].SubItems[3].Text = this.textBox3.Text; this.LvFriends.SelectedItems[0].SubItems[4].Text = this.comboBox2.Text; this.LvFriends.SelectedItems[0].ImageIndex=InfoHelper.imageIndex; MessageBox.Show("修改成功!"); ClearTextBox(); } } private void UpdateFriends_Load(object sender, EventArgs e) { } private void LvFriends_SelectedIndexChanged(object sender, EventArgs e) { if(this.LvFriends.SelectedItems.Count!=0) { ListViewItem lvi=this.LvFriends.SelectedItems[0]; this.textBox1.Text=lvi.SubItems[0].Text; this.comboBox1.Text=lvi.SubItems[1].Text; this.textBox2.Text=lvi.SubItems[2].Text; this.textBox3.Text=lvi.SubItems[3].Text; this.comboBox2.Text=lvi.SubItems[4].Text; tusing System; using System.Collections.Generic; using using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace AddressListExample { public partial class SearchInfoFrm : Form { public SearchInfoFrm() { InitializeComponent(); } private void SearchInfoFrm_Load(object sender, EventArgs e) { for (int i = 0; i < InfoHelper.groupsCount; i++) { TreeNode tn = new TreeNode(InfoHelper.groups[i]); tn.Tag = i; for (int j = 0; j < InfoHelper.friendsCount; j++) { if (InfoHelper.friendsGroup[j] == i) { TreeNode temp = new TreeNode(InfoHelper.frinedsName[j]); temp.Tag = j; tn.Nodes.Add(temp); } } this.tvNodes.Nodes.Add(tn); } } private void tvNodes_AfterSelect(object sender, TreeViewEventArgs e) { TreeNode temp = this.tvNodes.SelectedNode; if(temp != null ) { this.listView1.Items.Clear(); if (temp.Level == 0) { int groupIndex = Convert.ToInt32(temp.Tag); } else { int groupIndex = Convert.ToInt32(temp.Tag); } } } } } his.pictureBox1.Image=ilPhotos.Images[InfoHelper.imageIndex];
}
}
}
[/color]
}这是编写的添加联系人的代码,求大神指导后面查找联系人的代码