| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 311 人关注过本帖
标题:制作一个简单的通讯录,求指导如何进行信息查询
只看楼主 加入收藏
Tanni
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-3-22
收藏
 问题点数:0 回复次数:0 
制作一个简单的通讯录,求指导如何进行信息查询
我是个新手,刚学的C#
程序代码:
[color=#0000FF]using 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 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]
}这是编写的添加联系人的代码,求大神指导后面查找联系人的代码
 
搜索更多相关主题的帖子: 查询 信息 通讯录 如何 制作 
2012-03-22 15:12
快速回复:制作一个简单的通讯录,求指导如何进行信息查询
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023945 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved