| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1056 人关注过本帖
标题:小仙哥哥请帮忙看看
只看楼主 加入收藏
小仙
Rank: 7Rank: 7Rank: 7
来 自:光之谷
等 级:贵宾
威 望:39
帖 子:1812
专家分:1
注 册:2008-8-8
收藏
得分:0 
public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        Users us = new Users();
        private void Form1_Load(object sender, EventArgs e)
        {
            Users uss = new Users();
            User u = new User();
            u.name = "aaa";
            u.pwd = "111";
            uss.Add(u);
            u = new User();
            u.name = "bbb";
            u.pwd = "222";
            uss.Add(u);
            u = new User();
            u.name = "ccc";
            u.pwd = "333";
            uss.Add(u);
            dataGridView1.DataSource = uss;
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            
        }

        private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            
            User u = new User();
            u.name = dataGridView1.SelectedRows[0].Cells["name"].Value.ToString();
            u.pwd = dataGridView1.SelectedRows[0].Cells["pwd"].Value.ToString();
            if (us.Count != 0)
            {
                foreach (User uu in us)
                {
                    if (u.name == uu.name)
                    {
                        MessageBox.Show("已经添加!");
                        return;
                    }
                }
                us.Add(u);
                dataGridView2.DataSource = us;
                dataGridView2.DataSource = null;
                dataGridView2.DataSource = us;
            }
            else
            {
                //dataGridView2.DataSource = null;
                us.Add(u);
                dataGridView2.DataSource = us;
            }
        }
    }


class User
    {
        private string m_Name;

        public string name
        {
            get { return m_Name; }
            set { m_Name = value; }
        }
        private string m_Pwd;

        public string pwd
        {
            get { return m_Pwd; }
            set { m_Pwd = value; }
        }
    }


    class Users :List<User>
    {
   
    }


仁者乐膳,智者乐睡。我都爱~
2008-10-10 15:04
乖老鼠
Rank: 5Rank: 5
来 自:四川省
等 级:职业侠客
威 望:2
帖 子:434
专家分:394
注 册:2008-9-8
收藏
得分:0 
LS太敬业了

转眼就从编程菜鸟混成了半灌水
2008-10-10 17:46
huchao0911
Rank: 1
等 级:新手上路
帖 子:55
专家分:5
注 册:2008-4-25
收藏
得分:0 
呵呵,小仙牛了,一气呵成啊
2008-10-10 17:55
快速回复:小仙哥哥请帮忙看看
数据加载中...
 
   



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

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