如题各位大侠,小弟新手,想豌豆荚通讯录列表的要怎么实现啊。
我用winfrom的用户控件做了个,但是效率太差了。
求帮助

解决方案 »

  1.   

    你用哪个控件?ListView效率还是非常高的
      

  2.   

    UP UP!!!
    416310531知道的大侠求帮助,这我QQ
      

  3.   

    Reflector??反编译,还是?额
      

  4.   

    两个方案,第一个是修改listview,搜索后就能知道。
    第二个比较麻烦但是简单,就是在panel中动态添加你需要的项目组合。namespace WindowsFormsApplication2
    {
        partial class Form1
        {
            /// <summary>
            /// 必需的设计器变量。
            /// </summary>
            private System.ComponentModel.IContainer components = null;        /// <summary>
            /// 清理所有正在使用的资源。
            /// </summary>
            /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
            protected override void Dispose(bool disposing)
            {
                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }        #region Windows 窗体设计器生成的代码        /// <summary>
            /// 设计器支持所需的方法 - 不要
            /// 使用代码编辑器修改此方法的内容。
            /// </summary>
            private void InitializeComponent()
            {
                this.panel1 = new System.Windows.Forms.Panel();
                this.button1 = new System.Windows.Forms.Button();
                this.SuspendLayout();
                // 
                // panel1
                // 
                this.panel1.Location = new System.Drawing.Point(12, 12);
                this.panel1.Name = "panel1";
                this.panel1.Size = new System.Drawing.Size(260, 205);
                this.panel1.TabIndex = 0;
                // 
                // button1
                // 
                this.button1.Location = new System.Drawing.Point(197, 223);
                this.button1.Name = "button1";
                this.button1.Size = new System.Drawing.Size(75, 23);
                this.button1.TabIndex = 1;
                this.button1.Text = "button1";
                this.button1.UseVisualStyleBackColor = true;
                this.button1.Click += new System.EventHandler(this.button1_Click);
                // 
                // Form1
                // 
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(284, 261);
                this.Controls.Add(this.button1);
                this.Controls.Add(this.panel1);
                this.Name = "Form1";
                this.Text = "Form1";
                this.ResumeLayout(false);        }        #endregion        private System.Windows.Forms.Panel panel1;
            private System.Windows.Forms.Button button1;
        }
    }
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;namespace WindowsFormsApplication2
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void button1_Click(object sender, EventArgs e)
            {
                panel1.AutoScroll = true;
                for (int i = 0; i < 20; i++)
                {
                    Panel pan = new Panel();
                    pan.Width = 126;
                    pan.Height = 46;
                    PictureBox pic = new PictureBox();
                    pic.BackColor = Color.Red;
                    pic.Width = 40;
                    pic.Height = 40;
                    pic.Location = new Point(2, 3);
                    pan.Controls.Add(pic);
                    Label lbname = new Label();
                    lbname.Height = 20;
                    lbname.Location = new Point(44, 3);
                    pan.Controls.Add(lbname);
                    lbname.Text = "name" + i.ToString();
                    Label lbtel = new Label();
                    lbtel.Height = 20;
                    lbtel.Text = i.ToString("00000000");
                    lbtel.Location = new Point(44, 25);
                    pan.Controls.Add(lbtel);
                    pan.Location = new Point(2, i * 47);
                    panel1.Controls.Add(pan);
                }
            }
        }
    }
      

  5.   

    上面部分是一个简单的for next循环生成的简单界面,你需要动态调用等属性,自己修改循环就可以了。
    显示部分用了两个lable,如果需要别的东西你自己调整一下。
    截获点击事件的问题,可以在pic的tag里面添加区别字段或其他区别对象,然后写统一的pic_click事件委托就可以了。我稍微修改一下后面的代码发给你。
    以下是修改后的点击代码和委托代码。        private void button1_Click(object sender, EventArgs e)
            {
                panel1.AutoScroll = true;
                for (int i = 0; i < 20; i++)
                {
                    Panel pan = new Panel();
                    pan.Width = 126;
                    pan.Height = 46;
                    PictureBox pic = new PictureBox();
                    pic.BackColor = Color.Red;
                    pic.Width = 40;
                    pic.Height = 40;
                    pic.Tag = i.ToString();
                    pic.Click += new EventHandler(pic_Click);
                    pic.Location = new Point(2, 3);
                    pan.Controls.Add(pic);
                    Label lbname = new Label();
                    lbname.Height = 20;
                    lbname.Location = new Point(44, 3);
                    pan.Controls.Add(lbname);
                    lbname.Text = "name" + i.ToString();
                    Label lbtel = new Label();
                    lbtel.Height = 20;
                    lbtel.Text = i.ToString("00000000");
                    lbtel.Location = new Point(44, 25);
                    pan.Controls.Add(lbtel);
                    pan.Location = new Point(2, i * 47);
                    panel1.Controls.Add(pan);
                }
            }        void pic_Click(object sender, EventArgs e)
            {
                MessageBox.Show(((PictureBox)sender).Tag.ToString());
            }
      

  6.   

      谢谢  xomix ,还有个问题,当用panel循环1000个就出现瓶颈,界面很卡。循环完以后拉下拉滚动条也是卡的。很头疼
      

  7.   

    {
                panel1.SuspendLayout();
                panel1.AutoScroll = true;
                Panel[] pans = new Panel[1000];
                for (int i = 0; i < pans.Length; i++)
                {
                    pans[i] = new Panel();
                    pans[i].Width = 126;
                    pans[i].Height = 46;
                    PictureBox pic = new PictureBox();
                    pic.BackColor = Color.Red;
                    pic.Width = 40;
                    pic.Height = 40;
                    pic.Location = new Point(2, 3);
                    pans[i].Controls.Add(pic);
                    Label lbname = new Label();
                    lbname.Height = 20;
                    lbname.Location = new Point(44, 3);
                    pans[i].Controls.Add(lbname);
                    lbname.Text = "name" + i.ToString();
                    Label lbtel = new Label();
                    lbtel.Height = 20;
                    lbtel.Text = i.ToString("00000000");
                    lbtel.Location = new Point(44, 25);
                    pans[i].Controls.Add(lbtel);
                    pans[i].Location = new Point(2, i * 47);
                }        
                    
                panel1.Controls.AddRange(pans);
                panel1.ResumeLayout();
            }        private void Form1_Load(object sender, EventArgs e)
            {
                this.DoubleBuffered = true;
            }
      

  8.   


    SocketUp,xomix  当我循环1000个的时候果断只显示出692个停了!
    Listview可以实现么? 
      

  9.   

    循环1000次,窗体上大概有4000个控件了
    使用GDI+画吧
      

  10.   

    Listview 重写实现可以不呢? 
      我搞不懂怎么重写蛋疼的新手!
      

  11.   

    up!up!
    求,winfrom完成的和360手机助手中联系人一样的列表!
      

  12.   

    1000个。。你可以分页显示一下么。我相信就是listview你这么做也很卡的,做个变量分页显示,自动剔除前面的增加后面的吧。。否则没好的解决方案。
      

  13.   

    关于分页不想显示分页等,建议整合在滚动中。具体我现在只有个思路,没代码。
    在添加的时候加个if,判断controls数量多大,然后如果大于多少就自动删除tag小的多少条增加大的多少条这样做。
      

  14.   


    嗯,不错的思路,我试试呢。谢谢 xomix